Unable to update datagrid with new data
Posted: Sat May 31, 2014 1:36 pm
Followed this tutorial which explains how to add checkboxes to datagrid rows instead of using selection (required because of mobile devices):
http://lessons.runrev.com/m/datagrid/l/ ... -data-grid
Nice, but it does not explain how to implement a handler that will execute once a checkbox was checked or unchecked.
My solution in the behaviour onMouseUp script: dispatch "dgSelectedIndexChanged" with the dgindex of me
In the card script:
answer "after dgDate update" is never executed. set the dgDate of group "DataGrid 1" to theData fails completely.
Why is it not possible to update the dgData this way? I use the normal message path.
How can I get this right? I need to know when the status is changing so that I can act up on each change.
AFTER SOME DATAGRID SCRIPT DEBUGGING
I found out that the error is happening in private command _list.DeleteControls after the extra cleanup comment in the second repeat which deletes a control 1 in dgList.
After I've commented out this section it worked. So for me this is a datagrid bug which I opened a bug report already.
After some more debugging I discovered that dgList is the list that contains all rows. The repeat loop loops through all the row templates and removes each one. I guess before the new data can be populated.
I assume at the moment that the onMouseUp command within the row behaviour is still executing while the code to cleanup the dgList is running and therefore the data can't be written or is written but just deleted again, because the repeat will continue while it finds rows.
So it could be that this is not a bug. But then I still wonder how I can send a message that indicates that something has changed and action is required.
Reminds me about the Monkey Island Adventure Game: Get the meat, and the pot. Chase the bird away by rocking the plank.When it flies away, get the fish. Go to the circus, put the pot on head, get in canon.... It's about the same complex logic.
Kind regards,
Chris
http://lessons.runrev.com/m/datagrid/l/ ... -data-grid
Nice, but it does not explain how to implement a handler that will execute once a checkbox was checked or unchecked.
My solution in the behaviour onMouseUp script: dispatch "dgSelectedIndexChanged" with the dgindex of me
Code: Select all
on mouseUp pMouseBtnNum
if pMouseBtnNum is 1 then
## did they click on the checkbox?
if the short name of the target is "Check" then
## Update internal value in data grid
SetDataOfLine the dgLine of me, "checked", the hilite of the target
dispatch "dgSelectedIndexChanged" with the dgIndex of me -- added this message for which i implement the command in the card script
end if
end if
end mouseUp
Code: Select all
on dgSelectedIndexChanged pIndex
local theDataA
put "Line 3" into theDataA[1]["label"]
put "true" into theDataA[1]["checked"]
put "Line 4" into theDataA[2]["label"]
put "false" into theDataA[2]["checked"]
answer "before dgData update"
set the dgData of group "DataGrid 1" to theDataA
answer "after dgData update"
end dgSelectedIndexChanged
Why is it not possible to update the dgData this way? I use the normal message path.
How can I get this right? I need to know when the status is changing so that I can act up on each change.
AFTER SOME DATAGRID SCRIPT DEBUGGING
I found out that the error is happening in private command _list.DeleteControls after the extra cleanup comment in the second repeat which deletes a control 1 in dgList.
Code: Select all
## Any extra cleanup
repeat until there is not a (group 1 of group "dgList" of me)
delete group 1 of group "dgList" of me
end repeat
-- answer "_list.DeleteControls after extra cleanup"
-- repeat until there is not a control 1 of group "dgList" of me
-- answer the short id of control 1 of group "dgList" of me
-- delete control 1 of group "dgList" of me
-- end repeat
After some more debugging I discovered that dgList is the list that contains all rows. The repeat loop loops through all the row templates and removes each one. I guess before the new data can be populated.
I assume at the moment that the onMouseUp command within the row behaviour is still executing while the code to cleanup the dgList is running and therefore the data can't be written or is written but just deleted again, because the repeat will continue while it finds rows.
So it could be that this is not a bug. But then I still wonder how I can send a message that indicates that something has changed and action is required.
Reminds me about the Monkey Island Adventure Game: Get the meat, and the pot. Chase the bird away by rocking the plank.When it flies away, get the fish. Go to the circus, put the pot on head, get in canon.... It's about the same complex logic.

Kind regards,
Chris