Page 1 of 1

How to dynamically build a datagrid table

Posted: Fri Oct 14, 2016 9:06 pm
by William Jamieson
Hello, it has been a while since i used the datagrid and had a simple question about datagrid tables. Maybe it is so simple, that I couldnt find any other threads on it so I decided to ask.

If I were to query a database and pull out tables X, Y, and Z. And say I had a template for each X Y and Z and a behavior for each as well. But I didn't know in what order they will appear, sometimes X is first, sometimes Z. And they could appear multiple times and I need to label the columns accordingly and sometimes build as many as 20 columns. How would I go about doing that?

I looked at the api and was looking for function like "dgCreateColumn" or "dgSetColumnLabel" but I didn't see anything. Did I miss something?

-Will

Re: How to dynamically build a datagrid table

Posted: Fri Oct 14, 2016 10:12 pm
by Klaus
Hi Will,

you want to set a couple of properties:

Code: Select all

...
set the dgProp["columns"] of grp "your dg here" to cr_delimited_list_of_columns
set the dgProp["column labels"] of grp "your dg here" to cr_delimited_list_of_column_labels
...
Grab your PDF copy of the complete datagrid docs here: http://lessons.livecode.com/m/datagrid_tips
A TINY link, must be seven points or something, :? sigh, under the Topics on the left side.

I read it up again and again and again whenever I need to work with datagrids!
Or answer DG related questions here in the forum. :D


Best

Klaus

Re: How to dynamically build a datagrid table

Posted: Sat Oct 15, 2016 4:20 am
by William Jamieson
Thanks klaus! Exactly what i was missing

Re: How to dynamically build a datagrid table

Posted: Sat Oct 15, 2016 10:10 pm
by jameshale
The PDF Klaus has referred you to has not been updated to use the current IDE interface.
If you are using LC 8.1 or above please check out the included Dat Grid guide.
It has been updated to the version 8 interface which helps in doing the exercises.
You access it via the "Guide" tab in the Dictionary window.

Re: How to dynamically build a datagrid table

Posted: Sat Oct 15, 2016 11:45 pm
by Klaus
Yes, sorry, I forgot that the docs are now in the dictionary in LC 8.1! :oops:

Re: How to dynamically build a datagrid table

Posted: Sun Oct 23, 2016 8:17 pm
by William Jamieson
Im sad to say that is what I was using :oops: , I just didnt see the dgProps["columns"]. I must have just missed it.

Thanks!