Resizing datagrid columns automatically

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
stam
Posts: 2686
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Resizing datagrid columns automatically

Post by stam » Sun Jul 26, 2020 3:39 am

Hi all,
Can't find clear answer to this, hopefully someone here can answer:

I have a datagrid with 3 columns that occupies the width of a stack.
I want the columns to resize when the stack resizes so that extra 'non-column' doesn't appear.

I edited the on resizeStack pNewWidth, pNewHeight, pOldWidth, pOldHeight handler in the card script with

Code: Select all

set the dgColumnWidth["col 1"] of group "data grid 1" to round(pNewWidth/3)
set the dgColumnWidth["col 2"] of group "data grid 1" to round(pNewWidth/3)
set the dgColumnWidth["col 3"] of group "data grid 1" to round(pNewWidth/3)
Great - this works just fine. All columns resize proportionally as planned.

I then wanted to use the row/column template for formatting but can't - the '+' buttons just don't do anything when clicked and it's not possible to add behaviour/templates.

As a test, I then created a new stack with a similar data grid, but this time i created the row/column templates first.
Great, thant works fine.
BUT - when i put the above script in the card's 'On resizeStack' handler, nothing happens - i can't resize the columns when resizing the stack this way if a template is set, it seems.

It seems that you can't only use templates/behavious if none of the data grid's properties are modified elsewhere? And if you do have templates then you can't modify the data grid properties from scripts elsewhere?

Is it possible to get access the datagrid width from within the template? how else would you resize columns?

stam
Posts: 2686
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Resizing datagrid columns automatically

Post by stam » Sun Jul 26, 2020 2:38 pm

Actually this wasn't a reproducible problem.
I think the issues i had when creating a new stack is that i just copy/pasted the data grid that was problematic into a new stack.
I deleted all references to this in the original stack and started from scratch, this now works as expected.
Please ignore my post and/or delete as necessary.

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”