DataGrid and my headache

Bob Sneidar bobs at twft.com
Wed Sep 7 12:16:49 EDT 2011


I made the same mistake at first. There are column LABELS and column NAMES. They can be different, and it can be a gotcha. It's the column NAMES that are important. It's actually a good thing, as I discovered I could use an array from sqlYoga by calling sqlquery_retrieveAsArray, and then set the datagrid data using set the dgData of group "myDataGrid1" to that array. Any datagrid columns named the same as the sql columns will display the data, but NOT discard the "invisible" data. That remains intact and accessible using the dgDataOfIndex[indexnum] making the datagrid array a kind of sql temporary storage. Now I can reference the unique key which is invisible to the user when I want to update my sql table, along with any other data from the table. 

In one project I have a datagrid that is a part of a repeating background on several cards that act as forms for various sql tables. In my opencard handler, I get a property of the card containing the sql column names I want to display along with widths and column labels. I set the 3 properties of the datagrid called dgProp["columns"], dgProp["widths"] and dgprop["labels"] from that saved property data, I get the sql data as an array, and I set the dgData of the datagrid to that. I now have a method that will work with any sql table now using the same code in any of my future projects. 

If you intend to do a lot of work with datagrids, I would get used to using the array functions as opposed to the text functions as soon as possible. Parsing the text with all the repeat loops and what have you turns out to be much more troublesome in the long run. 

Bob


On Sep 7, 2011, at 8:38 AM, Mark Wieder wrote:

> Trevor-
> 
> Tuesday, September 6, 2011, 9:32:33 PM, you wrote:
> 
>> Odd. I just went through the lesson step-by-step for a third time and it
>> worked just fine. The only change I made was to the name of the data grid in
>> the code (as recommended by the instructions). Did you change the column
>> names to "state" and "code"?
> 
> Ah. No, I didn't. Is it necessary to name them "state" and "code" for
> this to work? That's already in the first line of the text, so it
> seems like a redundant step. I did make sure the columns were properly
> created and work properly with the extra code added. Do the column
> names "Col 1" and "Col 2" have superpowers?
> 
> -- 
> -Mark Wieder
> mwieder at ahsoftware.net
> 
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode





More information about the use-livecode mailing list