Removing the last empty column in datagrid

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
vladoportos
Posts: 17
Joined: Wed Jun 20, 2012 8:21 pm

Removing the last empty column in datagrid

Post by vladoportos » Thu Jul 05, 2012 10:42 am

Hello all,

This might be realy stupid question as I looked through this forum and nobody asked it before :) so either I'm doing something wrong or everybody figure it out...

When I have datagrid with, lets say, 4 columns there is always 5th empty one... why is that ? Or better yet how I can get rid of it ?

See attached picture

Thanks.
Vladimir
Attachments
5thColumn.png

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

Re: Removing the last empty column in datagrid

Post by Klaus » Thu Jul 05, 2012 11:23 am

Hi Valdimir,

there is no 5th column, it just looks like :D

If the sum of the length of all your columns < the witdh of the datagrid,
then you see "empty space" in the rest of the datagrid.

The only way to get rid of this is to resize you columns until they fill
the complete datagrid.

Imagine a field which has less text in it than its height.
Nooone will wonder why there is so much space at the bottom!
Same with the datagrid :)


Best

Klaus

snm
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 253
Joined: Fri Dec 09, 2011 11:17 am

Re: Removing the last empty column in datagrid

Post by snm » Thu Jul 05, 2012 12:52 pm

You can drag the last column header divider to the right edge of DataGrid if you have dColumnsResizable property set to true.

Marek

vladoportos
Posts: 17
Joined: Wed Jun 20, 2012 8:21 pm

Re: Removing the last empty column in datagrid

Post by vladoportos » Thu Jul 05, 2012 2:25 pm

Thanks both, I thought it was something simple / strange :)

I will look in help how to resize the last divider to the right

Vlad

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

Re: Removing the last empty column in datagrid

Post by Klaus » Thu Jul 05, 2012 2:47 pm

Hi Valdimir,

1. in the inspector for your datagrid select the column "Meno" and check "Drag to resize"
2. Resize your last column until it fits (and/or all other columns, too).
3. Uncheck "Drag to resize" for that column again
4. save your stack and be happy :D


Best

Klaus

snm
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 253
Joined: Fri Dec 09, 2011 11:17 am

Re: Removing the last empty column in datagrid

Post by snm » Thu Jul 05, 2012 2:57 pm

But it works only to the next stack resize. I thing that better and forever will be to set the width of last column to the width of DataGrid minus the sun of widths of rest columns and put such script step in proper handlers of the column behavior script. It should be also possible to put it in "on resizeStack" handler located in stack script, but I'm not sure.

Marek

vladoportos
Posts: 17
Joined: Wed Jun 20, 2012 8:21 pm

Re: Removing the last empty column in datagrid

Post by vladoportos » Thu Jul 05, 2012 5:59 pm

ok so code for it is like this:

Code: Select all

   -- put width of columns in variables ( last one is Meno ( name ) that we will set 
   put the dgColumnWidth["Typ"] of group "dGrid" into sTyp
   put the dgColumnWidth["Vyrobca"] of group "dGrid" into sVyrobca
   put the dgColumnWidth["Kategoria"] of group "dGrid" into sKategoria
   put the Width of group "dGrid" into full_size  --get full size
   
   -- next put the new lengt of last column based on full size - 15px ( thats the size of scroller so the bottom scroller dont apear )
   -- and minus the size of the rest columns before the last
   put (full_size - 15 ) - (sTyp + sVyrobca + sKategoria ) into sMeno
   
   -- set the width of the last column
   set the dgColumnWidth["Meno"] of group "dGrid" to sMeno
The question is into which handler put this code ? I need it to happen when somebody resize the column manually, or the whole stack is resized.

vladoportos
Posts: 17
Joined: Wed Jun 20, 2012 8:21 pm

Re: Removing the last empty column in datagrid

Post by vladoportos » Tue Jul 10, 2012 8:33 am

Ok if somebody needs it than put it into

Code: Select all

on resizeControl
it will work accurately.

if I put it into

Code: Select all

on resizeStack
it would not update correctly with fast move ( if you drag the window too fast ) I rely don't know why is that.

Post Reply