Detect Column Resize In DataGrid

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
dickey
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 115
Joined: Wed Apr 08, 2009 11:54 pm

Detect Column Resize In DataGrid

Post by dickey » Thu Aug 11, 2011 4:57 am

Hello all,

I have coded my own filters for the DataGrid object.

I have a field that performs a type ahead search across all the columns of the DataGrid (background/irrelevant), and a collection of fields sitting above the header fields of the grid which perform a cumulative type ahead search upon the column to which they relate (relevant).

I was wondering,

+ in the first instance whether each field could inherit the width property from the corresponding column in the DataGrid, and if that were not possible;

+ in the second instance whether upon column resize in the DataGrid a message fires which I could customise to resize my filter fields to maintain a coherent width/alignment. I couldn't spot what I needed in the API, but I imagined a handler something like: on ResizeDataGridColumn pColumn -- I could then grab the column width and column margins for pColumn and apply them to my filter fields (or use get the dgFormattedWidth of group "xyz").

Using a similar technique I could then maintain the width/alignment of my column totals at the base of the DataGrid.

Any assistance greatly appreciated. Kind regards, Andrew

dickey
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 115
Joined: Wed Apr 08, 2009 11:54 pm

Re: Detect Column Resize In DataGrid

Post by dickey » Sun Aug 14, 2011 12:30 am

zryip theSlug was so kind as to email me the following solution via the LiveCode Developer List:
Hi Andrew,

You can use the dgColumnWidth property of the datagrid on the datagrid
group script to get the size of a column being resized..

setprop dgColumnWidth [pColumn] pValue
put pColumn & "Filter" into tColumnFilterField
put pColumn & "Sum" into tColumnSumField
changeRectOfField tColumnFilterField, pValue
changeRectOfField tColumnSumField, pValue

pass dgColumnWidth
end dgColumnWidth

Where:
- pColumn is the column name
- pValue is the column width
My thanks to zryip for his response.

Kind regards, Andrew

Post Reply