Obtaining user modified column width data

28 views
Skip to first unread message

Myles

unread,
Nov 25, 2009, 4:49:11 PM11/25/09
to Flexigrid for jQuery
I need to be able to obtain an AJAX event from Flexigrid when a user
changes the width of a column so I can save it in their display
preferences data on the server to refresh the grid the way that last
viewed it. I have all the backend facilities for this in place and
its working great for sort columns, sort order, rows per page, etc.
But the one thing I can't seem to see that is exposed is an array of
columns and their widths. Is this data returned back to my PHP
application via AJAX somehow so I can interogate it and store it for
future redisplays?

Myles

Darren

unread,
Nov 25, 2009, 7:57:50 PM11/25/09
to Flexigrid for jQuery
I am a little new to this control so forgive me if this is wrong.

Looking at the code, there is a getCellDim method.

getCellDim: function(obj) // get cell prop for editable event
{
var ht = parseInt($(obj).height());
var pht = parseInt($(obj).parent().height());
var wt = parseInt(obj.style.width);
var pwt = parseInt($(obj).parent().width());
var top = obj.offsetParent.offsetTop;
var left = obj.offsetParent.offsetLeft;
var pdl = parseInt($(obj).css('paddingLeft'));
var pdt = parseInt($(obj).css('paddingTop'));
return { ht: ht, wt: wt, top: top, left: left, pdl:
pdl, pdt: pdt, pht: pht, pwt: pwt };

Maybe you could grab a reference to a cell in a column, then call this
method to obtain all the details of that cell. This may not be perfect
as your after a column width which may include things like borders,
etc, etc but i guess this should give you a "close enough" value
possibly.

Myles

unread,
Nov 26, 2009, 10:31:32 AM11/26/09
to Flexigrid for jQuery
On Nov 25, 5:57 pm, Darren <dazmil...@gmail.com> wrote:
> Maybe you could grab a reference to a cell in a column, then call this
> method to obtain all the details of that cell. This may not be perfect
> as your after a column width which may include things like borders,
> etc, etc but i guess this should give you a "close enough" value
> possibly.

Thanks Darren. That might work as I don't need an exact down to the
pixel measurement. Its just that users are asking to resize column
widths now that they see their data in the grids (of course during
development I have no idea what their data is going to look like, so I
just set arbitrary values for column widths). They are complaining
that when they set the width to how they like to see the data, and
then come back to the page later, they have to do it all over again.

My hope was that Flexigrid would publish an array of the columns and
their widths just like how we set them up in the first place. I'm not
a Javascript guru (I'm a PHP developer) and I checked the data coming
back into my PHP app through AJAX but couldn't seem to get the exposed
columns and their widths as an array value. Do you think this could
be done easily?

Myles
Reply all
Reply to author
Forward
0 new messages