Hieght of data grid, without scrollbars

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
doobox
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 284
Joined: Tue May 24, 2011 11:47 pm

Hieght of data grid, without scrollbars

Post by doobox » Sat Jul 09, 2011 9:45 am

Hi there,

I am trying to get a data grid, for all intents and purposes, to re-size in height in the same fashion a text field does when fit content is selected.

I have a data grid inside a mobGUI scroller group. Set to form type. no scrollbars.
So at the moment i am testing with static content, a string on each row, some 20 rows.
So ok, i can set the height to suit at the moment.
But in the app the content will be generated by the user. So how can i get the data grid to re-size it's height dependent on the size of the content.

I can think of a way to script this. Count the number of rows present and multiply by my row height, then set the height to the answer.
Is this the only way to set the height of the grid when new content is generated...?
Kind Regards
Gary

https://www.doobox.co.uk

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10320
Joined: Wed May 06, 2009 2:28 pm

Re: Hieght of data grid, without scrollbars

Post by dunbarx » Sun Jul 10, 2011 4:27 am

I don't think that datagrids, as fields themselves do not, have any native property that expands (or contracts) them to fit content. The answer dialog, for example, does this but it and its ilk are a special case.

I don't use datagrids much, but what you propose sounds like a straightforward and logical method, what most would do with simple fields.There are many messages you can trap to update the dg's height, either before the user accesses or after he modifies the data.

Craig Newman

doobox
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 284
Joined: Tue May 24, 2011 11:47 pm

Re: Hieght of data grid, without scrollbars

Post by doobox » Sun Jul 10, 2011 10:59 am

Hi Craig,

Thank you...
If i understand you correctly, your saying even with a text field, there is not a way to mimic the behaviour of clicking "fit content" in the property inspector, at runtime.


I will run with my initial thought of updating the height based on the number of rows (known height).
Kind Regards
Gary

https://www.doobox.co.uk

Klaus
Posts: 14194
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Hieght of data grid, without scrollbars

Post by Klaus » Sun Jul 10, 2011 12:23 pm

Hi Gary,

for fields you can do:
...
set the height of fld X to the formattedheight of fld X
## same with width -> formattedwidth
...
But I did not find something similar for datagrids in the DataGrid docs.


Best

Klaus

doobox
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 284
Joined: Tue May 24, 2011 11:47 pm

Re: Hieght of data grid, without scrollbars

Post by doobox » Sun Jul 10, 2011 12:36 pm

Thank's Klaus,

This is almost as quick anyway, it just seemed at the start that it may have ended up a little long winded.

Code: Select all

 put the dgNumberOfLines of group "DataGrid 1" into tTempvar
   put tTempvar * 70 into tNewHeight
   set the height of group "DataGrid 1" to tNewHeight
Kind Regards
Gary

https://www.doobox.co.uk

strongbow
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 146
Joined: Mon Jul 31, 2006 1:39 am
Contact:

Re: Hieght of data grid, without scrollbars

Post by strongbow » Fri Dec 30, 2011 1:59 pm

Try

the dgFormattedHeight of grp "YourDataGridName"

HTH

cheers

Alan

Post Reply