How to dynamically build a datagrid table

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
William Jamieson
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 212
Joined: Fri Feb 01, 2013 1:31 am
Contact:

How to dynamically build a datagrid table

Post 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
Klaus
Posts: 14324
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: How to dynamically build a datagrid table

Post 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
William Jamieson
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 212
Joined: Fri Feb 01, 2013 1:31 am
Contact:

Re: How to dynamically build a datagrid table

Post by William Jamieson »

Thanks klaus! Exactly what i was missing
jameshale
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 494
Joined: Thu Sep 04, 2008 6:23 am

Re: How to dynamically build a datagrid table

Post 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.
Klaus
Posts: 14324
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: How to dynamically build a datagrid table

Post by Klaus »

Yes, sorry, I forgot that the docs are now in the dictionary in LC 8.1! :oops:
William Jamieson
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 212
Joined: Fri Feb 01, 2013 1:31 am
Contact:

Re: How to dynamically build a datagrid table

Post 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!
Post Reply