DataGrid Jump Start?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
DataGrid Jump Start?
Do DataGrids need some kind of priming to get then started? When I first open my application and then type the following into the message box:
dispatch "FindIndex" to group "DataGrid 5" of card "Animals" of stack "DAStoPF" with "DAS", "AUST SHEPHERD"
It returns zero. If I navigate to card 5 ('Animals') and then press the return key on the message box, I get a 16 returned. From that point on I can go to any card either in my main stack or any substack and try with a new breed it works fine. For example:
dispatch "FindIndex" to group "DataGrid 5" of card "Animals" of stack "DAStoPF" with "DAS", "BEAGLE"
returns 20
Under program control I never seem to be able to retrieve that index. My application has 5 different datagrids but they all have different names.
Any ideas?
Regards,
Larry
dispatch "FindIndex" to group "DataGrid 5" of card "Animals" of stack "DAStoPF" with "DAS", "AUST SHEPHERD"
It returns zero. If I navigate to card 5 ('Animals') and then press the return key on the message box, I get a 16 returned. From that point on I can go to any card either in my main stack or any substack and try with a new breed it works fine. For example:
dispatch "FindIndex" to group "DataGrid 5" of card "Animals" of stack "DAStoPF" with "DAS", "BEAGLE"
returns 20
Under program control I never seem to be able to retrieve that index. My application has 5 different datagrids but they all have different names.
Any ideas?
Regards,
Larry
-
- VIP Livecode Opensource Backer
- Posts: 1005
- Joined: Sat Apr 08, 2006 3:06 pm
- Contact:
Re: DataGrid Jump Start?
When storing data grid data persistently a copy of the internal array is stored in a custom property of the data grid. When the data grid is opened for the first time the data is moved from the custom property to the internal array. This is done during the preOpenControl message. The preopenControl message is sent when the control actually opens which is why FindIndex starts working after you navigate to the card.
Unfortunately a data grid doesn't get any messages from the engine before it is visually opened so I don't know of a central place where the data grid data could be restored.
A quick fix would be to update the dgData getProp handler in the data grid behavior script to look like the following:
You could then force the data grid data to be loaded by executing the following when your application launched, but without having to open the card the data grid is on:
You can access the data grid script by executing the following in the message box:
Try it out and let me know if it works. If it does then I can sneak it into the data grid behavior for the next Rev release.
Unfortunately a data grid doesn't get any messages from the engine before it is visually opened so I don't know of a central place where the data grid data could be restored.
A quick fix would be to update the dgData getProp handler in the data grid behavior script to look like the following:
Code: Select all
getprop dgData
if the keys of sDataArray is empty then _RestorePersistentData ## In case control hasn't been opened yet
return sDataArray
end dgData
Code: Select all
set the dgData of group "DataGrid 5" of card "Animals" of stack "DAStoPF" to the dgData of group "DataGrid 5" of card "Animals" of stack "DAStoPF"
Code: Select all
edit script of btn "Data Grid" of stack "revdatagridlibrary"
Trevor DeVore
ScreenSteps - https://www.screensteps.com
LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder
ScreenSteps - https://www.screensteps.com
LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder
Re: DataGrid Jump Start?
Thanks Trevor,
That worked just fine. Your fix is much more elegant than the one I devised. I had put the following in the OpenStack and it seemed to be working.
Am I correct in assuming that until you get this worked into future REV versions, it will be necessary for me to make this same change in any versions that I have already.
I would also like to try to make some changes in the revBrowser library. Do you have any commands like
that would allow me to try some changes there. In particular I woul like to look at the code there for a right-click on a browser image.
Thanks again.
Larry
That worked just fine. Your fix is much more elegant than the one I devised. I had put the following in the OpenStack and it seemed to be working.
Code: Select all
set the lockScreen to true
go to card 4
put the dgText of group "DataGrid 3" of card "Preferences" of stack "DAStoPF" into tGridData
put the dgText of group "DataGrid 4" of card "Preferences" of stack "DAStoPF" into tGridData
go to card 5
put the dgText of group "DataGrid 5" of card "Animals" of stack "DAStoPF" into tGridData
go to card 1
set the lockscreen to false
I would also like to try to make some changes in the revBrowser library. Do you have any commands like
edit script of btn "Data Grid" of stack "revdatagridlibrary"
that would allow me to try some changes there. In particular I woul like to look at the code there for a right-click on a browser image.
Thanks again.
Larry
Re: DataGrid Jump Start?
Interesting twist Trevor,
I actually have three different dataGrids that I want to 'prime'. It seems that your fix only works for the first one. The following code in openStack of my application primes dataGrid 3 but not the others. If I change the order I can get the first to prime but not the others.
If you see annything obvious let me know otherwise I can go back to my method.
Thanks again,
Larry
I actually have three different dataGrids that I want to 'prime'. It seems that your fix only works for the first one. The following code in openStack of my application primes dataGrid 3 but not the others. If I change the order I can get the first to prime but not the others.
Code: Select all
set the dgData of group "DataGrid 3" of card "Preferences" of stack "DAStoPF" to the dgData of group "DataGrid 3" of card "Preferences" of stack "DAStoPF"
set the dgData of group "DataGrid 5" of card "Animals" of stack "DAStoPF" to the dgData of group "DataGrid 5" of card "Animals" of stack "DAStoPF"
set the dgData of group "DataGrid 4" of card "Preferences" of stack "DAStoPF" to the dgData of group "DataGrid 4" of card "Preferences" of stack "DAStoPF"
Thanks again,
Larry
-
- VIP Livecode Opensource Backer
- Posts: 1005
- Joined: Sat Apr 08, 2006 3:06 pm
- Contact:
Re: DataGrid Jump Start?
Is the data grid data permanently stored in the grids on card "Animals" and "Preferences" or are you populating them in the preopencard/opencard handlers on those cards? If populating when the card opens then the primer trick won't work.
Trevor DeVore
ScreenSteps - https://www.screensteps.com
LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder
ScreenSteps - https://www.screensteps.com
LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder