Page 1 of 1
Create Data Grid under program control
Posted: Sun May 28, 2017 10:58 pm
by lohill
I would like to have a button with a script that will create a new stack (or Sub Stack) and place a Data Grid on it. Is that possible? If so which commands in the dictionary would be the most helpful.
Thanks,
Larry
Re: Create Data Grid under program control
Posted: Mon May 29, 2017 2:45 pm
by dunbarx
Hmmm.
Setting properties of the templateGroup only sets, er, the properties of a new group. It does not recreate the objects within a group. A DG has lots of objects within it.
You can always store a DG somewhere, even containing default or newly loaded data, copy it, and paste it to some target card. This can all be done invisibly.
Craig Newman
Re: Create Data Grid under program control
Posted: Mon May 29, 2017 11:22 pm
by lohill
Craig,
It has been years since I tried to 'copy' a data grid and paste the copy in a new place. This was because I always seemed to end up messing up something and I ultimately ended up blaming it on the datagrid construct itself. Are you saying that I should be able to create a DG on a card of one stack and then simply copy it to a card on another stack and it will have all its proper behaviors? (I guess that should be easy to test.)
Larry
Re: Create Data Grid under program control
Posted: Mon May 29, 2017 11:53 pm
by lohill
I just tried copying two datagrids and a couple of buttons along with all the scripts to another new stack. I tested the new stack and it seemed to work properly I saved that new stack. Then I quit Livecode and opened just the new stack and it still seems to work even though it has no Data Grid Templates substack. What gives?
Larry
Re: Create Data Grid under program control
Posted: Tue May 30, 2017 12:19 am
by lohill
Craig
Here is my resulting stack. (It is attached and has no substack for templates.) Does it work for you?
The button at the top left is used to connect to any SQLite database and to populate the datagrid at the left with the database's tables and views. If you double click on any one of the resulting tables/views it should show the field names and types in the second data grid. The button at the right does nothing at the moment. Ultimately it is supposed to create a new data grid with the 'selected' fields from the second data grid.
Larry
Re: Create Data Grid under program control
Posted: Tue May 30, 2017 12:25 am
by lohill
I guess I can't send you a LiveCode file even when I change the extension to 'test'.
Re: Create Data Grid under program control
Posted: Tue May 30, 2017 5:31 pm
by lohill
Here is a Dropbox link to the test described above.
https://www.dropbox.com/s/m21amyklglsfr ... ecode?dl=0
Larry