Using a DataGrid as a simple list control

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9567
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Using a DataGrid as a simple list control

Post by dunbarx » Tue May 29, 2018 2:19 pm

Simon.

Are you sure the textHeight is not empty? Know that in a newly created field, properties such as textHeight and lineHeight are empty unless you set them explicitly.

Craig

Simon Knight
Posts: 845
Joined: Wed Nov 04, 2009 11:41 am
Location: Gunthorpe, North Lincs, UK

Re: Using a DataGrid as a simple list control

Post by Simon Knight » Tue May 29, 2018 3:20 pm

I think they were populated but there again I'm getting some odd errors: the simple line Go to card 1 throws an error two restarts out of three.
best wishes
Skids

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9567
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Using a DataGrid as a simple list control

Post by dunbarx » Tue May 29, 2018 7:31 pm

Hi.

Populating a field does not explicitly give it those properties. Make a new field. In msg, write:

Code: Select all

answer 5 / the textHeight of last field
You will get an error about dividing by 0. Actually, dividing by empty.

Not sure what to say about not being able to navigate. Maybe you have no card 1? :D

Craig

Simon Knight
Posts: 845
Joined: Wed Nov 04, 2009 11:41 am
Location: Gunthorpe, North Lincs, UK

Re: Using a DataGrid as a simple list control

Post by Simon Knight » Wed May 30, 2018 7:41 am

Ah that will be it, my cards are numbered with letters :D

A tech question about table fields if I may. Is it good practise to hide a column in a table by setting the table's tabstop property so that the column has the same value as the previous column e.g. 75,75,105,225 will hide column two?
best wishes
Skids

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Using a DataGrid as a simple list control

Post by bogs » Wed May 30, 2018 3:36 pm

Not on a dev machine at the moment, so might have this wrong, but my understanding is that tab stop sets the columns width, so any number represents a width, ie. 75,75,105,225 will make column two 75 pixels wide. If you wanted to hide the second column, I think it would be done using 0 or 1 like this - 75,0,105,225
Image

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9567
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Using a DataGrid as a simple list control

Post by dunbarx » Wed May 30, 2018 3:49 pm

The tabStops are set up so that each item depicts a fixed pixel value.

If you have "75,150,160" you will see a stop at those three xLocs.

However, if you have a fourth or subsequent stops, LC will take the difference of the last two explicit ones (160 - 150 = 10), and the later stops will all appear at that interval. So if you had more stops, they would appear at 170, 180, etc.

Craig

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Using a DataGrid as a simple list control

Post by bogs » Wed May 30, 2018 4:19 pm

Ok, was finally able to fire up the dev stuff, I was kinda right (0 does not work, 1 certainly does).
Selection_003.png
@Craig - That was interesting to find out, I didn't know it.

@Simon - The dictionary has a lot more interesting info in properties/tabstops.
Image

Simon Knight
Posts: 845
Joined: Wed Nov 04, 2009 11:41 am
Location: Gunthorpe, North Lincs, UK

Re: Using a DataGrid as a simple list control

Post by Simon Knight » Wed May 30, 2018 9:58 pm

Thanks all however my question was one of good practise when using a table field. In the past (draw up a sandbag!) you had to do some maths to enter the correct settings either by code using the tabstops command or entry via the inspector. For example say I wanted columns of 20, 30 , 50 and 10 pixels width I would have to enter tabstops of 20,50,100,110 i.e. the distance from the left margin.

At some point in the past LC was updated and the tabwidths command was added. This command (tabwidths) allows the tabs to be set as column widths i.e. 20,30,50,10 in the example.

At the same time they also changed how tabstops accepts data. It works as described above until a value is entered that would in effect place the tab to the left of the previous one e.g.If I enter 10,20,50,10 it changes the entry to 10,20,50,60 giving column widths of 10,10,30,10 pixels.

To hide a column I enter a column width of 0 using tabwidths or if for example I use tabstops I enter 10,20,20,60 this will mean that the third column is hidden as it is the same position as the previous tabstop. My question is is this a good idea - will it cause problems with the hidden data in the column?
best wishes
Skids

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7210
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Using a DataGrid as a simple list control

Post by jacque » Thu May 31, 2018 5:51 pm

It shouldn't cause any problems at all, the hidden tabs were created specifically to address what you want to do - - keep the data without displaying it so that scripts can work with it but the user never sees it.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Simon Knight
Posts: 845
Joined: Wed Nov 04, 2009 11:41 am
Location: Gunthorpe, North Lincs, UK

Re: Using a DataGrid as a simple list control

Post by Simon Knight » Thu May 31, 2018 5:55 pm

Hi Jacque,

Thanks for the confirming its o.k.
best wishes
Skids

Post Reply

Return to “Talking LiveCode”