DataGrid vs Field Behavior

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

DataGrid vs Field Behavior

Post by lohill » Mon May 23, 2011 9:44 pm

Intuitively, I expect a group containing a field and a datagrid to have similar behaviors on the cards of a stack. This is not what I experience in this following simple example.
1. Make a new stack and on the first card place a field and a datagrid.
2. Select both objects and use the Object menu to make a group of them.
3. Select the group and go to the Inspector and check the box for 'Behave like a background'.
4. Make a new card and it will contain both a field and a datagrid (the group).
5. Go to the first card and type something in the field and then type something different in the field there.
6. You can go back and forth between cards and they would hold their field values. You could create a third card and it would have a blank field. Type something different in that field and all three cards will maintain their distinct values.
7. Now go back to card and put some contents into that datagrid by going to the inspector and the tab for contents. As an example type 'one' tab 'one'. When the inspector is closed you will see data in the grid.
8. Now go to card 2 and using the Inspector create the contents of 'two' tab 'two. On closing the inspector you will see that the grid has data in it.
9. Go back to card 1 and look at the datagrid. It shows nothing while I would expect it to show the original 'one' and 'one'.
10. Finally go to the Inspector for the datagrid on that card and check out the contents. You will see 'two' tab 'two' even though nothing appears to be showing. By going back to the Basic Properties option of the Inspector and taking the Refresh Data Grid option you will be able to see the 'two' and 'two' now on card 1.
11. A quick trip back to card 2 and you will find nothing visible in the grid anymore.

Why won't the datagrid as part of the background retain its individual information like the field does? Am I doing something incorrectly or do I have to put only the field in the background and have a different datagrid for each card.

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1239
Joined: Sat Apr 08, 2006 1:10 pm
Contact:

Re: DataGrid vs Field Behavior

Post by BvG » Tue May 24, 2011 11:56 am

the datagrid most likely does not set the "sharedText" property of its fields. Instead it depends on message to decide when to show what. I suggest to look at the lessons:

http://lessons.runrev.com/spaces/lesson ... s/datagrid
http://lessons.runrev.com/spaces/lesson ... agrid_tips

I assume you'd be expected to issue a data grid refresh on opencard?
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

lohill
Posts: 770
Joined: Tue Dec 08, 2009 6:37 pm

Re: DataGrid vs Field Behavior

Post by lohill » Tue May 24, 2011 9:14 pm

BvG,

I can see how the "sharedText" property works for fields from card to card. What I am looking for is a "DoNotshareText" property from data grid to data grid. There doesn't appear to be any such setting in the Property Inspector and I have already searched the tutorials you cited and have found nothing to help me with this issue. I realize that specific data for each grid could be saved externally and then loaded with either 'set the dgData of...to...' or 'set the dgText of ...to ...' but that seems like a waste of time to constantly have to load each card as you move to it.

I visited this problem in my project some months ago and ended up by not putting DataGrid 1 in the background but simply putting a "DataGrid 1" on each card. In this way each grid can be filled with its own data and since each has the name "DataGrid 1", the code in my program can talk to the grid on whatever card is being viewed. It works but the geometry is pretty tricky with some stuff in the background while the data grids are independent. It was sweating this out that I came back to test the data grid element and still cold not make it work.

If you can take my simple example and show me that you can make it work that would be great. On the other hand Trevor might just chime in and say the two behaviors - field and datagrid - are decidedly different as background elements.

Regard,
Larry

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1239
Joined: Sat Apr 08, 2006 1:10 pm
Contact:

Re: DataGrid vs Field Behavior

Post by BvG » Tue May 24, 2011 10:53 pm

as i said i don't use the dg.

just do whatever you want on opencard or preopencard.
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

lohill
Posts: 770
Joined: Tue Dec 08, 2009 6:37 pm

Re: DataGrid vs Field Behavior

Post by lohill » Fri May 27, 2011 12:24 am

Does anyone who actually uses datagrids have a definitive answer to my question? Aside from oddities like this, I find them to be very useful structures.

Regards,
Larry

Post Reply