Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
chriswood
- Posts: 23
- Joined: Mon Feb 23, 2009 2:27 am
Post
by chriswood » Sat Oct 17, 2009 3:54 am
How would one go about changing the dgprops or dgdata of a datagrid on a card that hasn't yet been shown?
In the following scenario the button to load data appears on card1 and the DataGrid itself is on card2
Script 1 works:
Code: Select all
go to card "card2"
set the dgprops ["columns"] of group "DataGrid 1" to tcColumnNames
set the dgprops ["column labels"] of group "DataGrid 1" to tcColumnLabels
set the dgprops ["column visibility"] of group "DataGrid 1" to tcColumnVisibility
set the dgprops ["column widths"] of group "DataGrid 1" to tcColumnWidths
--Yuk! screen updating is shown
Script 2 fails:
Code: Select all
--loading data takes a few seconds so show loading GIF
set the visible of image "OSXSpinnerGIF" to true
set the dgprops ["columns"] of group "DataGrid 1" of card "card2" to tcColumnNames
set the dgprops ["column labels"] of group "DataGrid 1" of card "card2" to tcColumnLabels
set the dgprops ["column visibility"] of group "DataGrid 1" of card "card2" to tcColumnVisibility
set the dgprops ["column widths"] of group "DataGrid 1" of card "card2" to tcColumnWidths
set the visible of image "OSXSpinnerGIF" to false
go to card "card2"
I have a test stack set up which I'll gladly email to anybody who wants to give it a try. Tested on OSX & XP rev 3.5 (some weirdness on XP) and 4 dp4
Best Regards
Chris
-
trevordevore
- VIP Livecode Opensource Backer

- Posts: 1005
- Joined: Sat Apr 08, 2006 3:06 pm
-
Contact:
Post
by trevordevore » Sat Oct 17, 2009 7:00 pm
Some Data Grid opertaions won't work if the Data Grid card isn't open. Setting the "columns" is one of them as the Data Grid redraws some controls and the engine doesn't always report valid values for certain properties if a control isn't on an open card. I've made a note of this and will see if I can work around it in a future version.
For the time being try wrapping your Script 1 example in lock screen/unlock screen. That will keep the screen updating from being displayed.
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
-
chriswood
- Posts: 23
- Joined: Mon Feb 23, 2009 2:27 am
Post
by chriswood » Sun Oct 18, 2009 12:12 am
Trevor,
Thanks for clarifying. I was was hoping to avoid screen locking as it also freezes the animated loading GIF.
As not all the table columns in the grid need to be displayed - some were not visible anyway - I will look at loading only the minimum required dgprops (to speed up the DataGrid redraw) and access the data from a set of global arrays.
Best Regards
Chris