I ran into an inconsistency with the Polygrid
The Polygrid property pgDataOfRow returns the data for the row indicated
by what pgInternalPointer is set to. The pgData of the Polygrid is a 2D
array of the form array[n][columnName]value and pgDataOfRow returns a 1D
array of the form array[columnName]value.
Now the properties "AddDataAfter" (or "AddDataBefore") to add a row of
data to the Polygrid After )or Before) the row pointed to by
pgInternalPointer expects a 2D array of the same form as pgData or
array[n][columnName]value.
So, consider the follow use case where you want to remove a row of data
(the last row of a table) that displays subtotals for each column but
then later (upon some user action or whatever) you want to add it back
put the numberOfRows of widget "rwTableview" into N
set the pgInternalPointer of widget "rwTableview" to N
put the pgDataOfRow of widget "rwTableview" into
sColSubtotalArray -- save the subtotal row in the form
sColSubtotalArray[columnName]value, a 1D array
set the pgDeleteRow of widget "rwTableview" to N -- delete
the subtotal row
And now you want to add it back
put the numberOfRows of widget "rwTableview" into N
set the pgInternalPointer of widget "rwTableview" to N
set the addDataAfter of widget "rwTableview" to
sColSubtotalArray
That LAST line (addDataAfter) will fail since the array saved by the
pgDataOfRow is a 1D array and addDataAfter expects a 2D array. If could
a simple repeat look through the keys of sColSubtotalArry will let you
build a new 2D array with 1 row and the columns being the keys or column
names, so it is not hard to convert, but SHOULD YOU HAVE TO?
You can convert with
put the number lines of the keys of sColSubtotalArray into N
repeat for each key tKey in sColSubtotalArray
put sColSubtotalArray[tKey] into tA[1][tKey]
end repeat
-- tA is now in the format that the addDataAfter property of the
Polygrid requires.
I am not sure this is a BUG. It is certainly an inconsistency and
changing it would break some current code. On the other hand, the
Polygrid is part of the widget set for Xavvi/Livecode Create and the
goal for that tool is to have things be super easy and super intuitive
for beginners (non-code or low-code app building) so I think beginners
would find thsi jarring.
So, is it a bug? What does the community think?
_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode