Create Data Grid under program control

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
lohill
Posts: 770
Joined: Tue Dec 08, 2009 6:37 pm
Location: San Diego, CA USA

Create Data Grid under program control

Post by lohill » Sun May 28, 2017 10:58 pm

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

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9580
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Create Data Grid under program control

Post by dunbarx » Mon May 29, 2017 2:45 pm

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

lohill
Posts: 770
Joined: Tue Dec 08, 2009 6:37 pm
Location: San Diego, CA USA

Re: Create Data Grid under program control

Post by lohill » Mon May 29, 2017 11:22 pm

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

lohill
Posts: 770
Joined: Tue Dec 08, 2009 6:37 pm
Location: San Diego, CA USA

Re: Create Data Grid under program control

Post by lohill » Mon May 29, 2017 11:53 pm

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

lohill
Posts: 770
Joined: Tue Dec 08, 2009 6:37 pm
Location: San Diego, CA USA

Re: Create Data Grid under program control

Post by lohill » Tue May 30, 2017 12:19 am

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

lohill
Posts: 770
Joined: Tue Dec 08, 2009 6:37 pm
Location: San Diego, CA USA

Re: Create Data Grid under program control

Post by lohill » Tue May 30, 2017 12:25 am

I guess I can't send you a LiveCode file even when I change the extension to 'test'.

lohill
Posts: 770
Joined: Tue Dec 08, 2009 6:37 pm
Location: San Diego, CA USA

Re: Create Data Grid under program control

Post by lohill » Tue May 30, 2017 5:31 pm

Here is a Dropbox link to the test described above.
https://www.dropbox.com/s/m21amyklglsfr ... ecode?dl=0

Larry

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”