Issue with DataGrid data not being up to date

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
buchacho
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 50
Joined: Fri Jun 14, 2013 10:22 pm

Issue with DataGrid data not being up to date

Post by buchacho » Fri Jul 12, 2013 11:10 pm

I am having this issue come up multiple times, where a data grid is updated:

Code: Select all

set the dgData of group "GeneralTableGrid" to GeneralTableArray
And it appears to be populated, but when another script tries to get the data, it is not really there. I have to go to the properties and then cut the contents (it is there), then paste the contents back in to refresh the table. After I do this, when I run the second script, it sees the data. Am I doing something wrong or is there a bug with data grids?

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: Issue with DataGrid data not being up to date

Post by dunbarx » Sat Jul 13, 2013 12:05 am

Hi.

I use dataGrids a lot. I do not understand them.

But if you do something like this:

Code: Select all

on mouseUp
   put "A" & tab & "B" & return & "C" & tab & "D" into temp
   set the dgtext of grp 1 to temp
end mouseUp
and then this:

Code: Select all

on mouseUp
   answer the dgtext of grp 1
end mouseUp
You do not get the data back?

That said, DataGrids do have to be refreshed after certain operations. There are a few ways to do this. The refresh button in the inspector, of course, or:

dispatch "ResetList" to group "yourDataGrid"

Craig Newman

buchacho
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 50
Joined: Fri Jun 14, 2013 10:22 pm

Re: Issue with DataGrid data not being up to date

Post by buchacho » Mon Jul 15, 2013 6:17 pm

I tried it, and it works. This issue seems to not be very consistent. I had also tried to press the "Refresh Data Grid" button in the properties inspector and it does not help. Cutting the data and re-pasting in the property inspector does help.

Essentially, I have multiple scripts that update the data grid via "set the dgData..." and then another script that uses that data, and sometimes that second script will appear to be misbehaving, but after spending a lot of time tracking the error, I find the data grid appears to be updated visually, but not "internally".

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: Issue with DataGrid data not being up to date

Post by dunbarx » Mon Jul 15, 2013 7:02 pm

Hi.

But if you dispatch the command, does it alway work from that point on?

Craig Newman

buchacho
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 50
Joined: Fri Jun 14, 2013 10:22 pm

Re: Issue with DataGrid data not being up to date

Post by buchacho » Mon Jul 15, 2013 9:58 pm

I have tried:

Code: Select all

dispatch "RefreshIndex" to group "GeneralTableGrid"
and now just tried:

Code: Select all

dispatch "ResetList" to group "GeneralTableGrid"
Both do not work. After that if I cut/paste the contents in the property manager, the subsequent script can then see the contents.

buchacho
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 50
Joined: Fri Jun 14, 2013 10:22 pm

Re: Issue with DataGrid data not being up to date

Post by buchacho » Tue Jul 16, 2013 6:04 pm

I think I made some progress here. I found that the script I was using to populate the data grid was starting with a counter that did not begin at 1, so the empty rows were in the grid's array, but the data grid does not show those empty rows. So when I was cutting and pasting the contents in the inspector, it was wiping out the empty rows. I think this behavior is a little odd still since it can lead to confusion and what if you wanted the first few rows empty for some reason?

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: Issue with DataGrid data not being up to date

Post by dunbarx » Tue Jul 16, 2013 7:25 pm

Take a brand new dataGrid named "CCC". Put this in a button script:

Code: Select all

on mouseUp
   put "" & tab & "" & return & "" & tab & ""  & return & "A" & tab & "B" & return & "C" & tab & "D" into temp
   set the dgText of grp "CCC" to temp
end mouseUp

Post Reply