This is a migrated thread and some comments may be shown as answers.

Retrieve column width on server side.

4 Answers 168 Views
Grid
This is a migrated thread and some comments may be shown as answers.
AndyL
Top achievements
Rank 1
AndyL asked on 03 Jul 2009, 08:44 PM
I have a page with a RadGrid (auto generated columns). I want to store how the user is setting their column sizes in Personalization so that it automatically reloads the column sizes each time they load the page/grid.

In order to do this I need to be able to (after a postback of some sort) retrieve the size (pixels) of the columns, but whenever I loop through the GridBoundColumns ItemStyle widths to get the value it is always blank.

How would I be able to get the width of the columns after a postback or partial postback?

4 Answers, 1 is accepted

Sort by
0
Accepted
Yavor
Telerik team
answered on 07 Jul 2009, 02:04 PM
Hello AndyL,

The best way to retrieve the width value for the column would be on the client. One possible approach in this case would be to store the value(s) in hidden inputs on the page. These controls will be accesible on the server, giving you a chance to get them there.
I hope this suggestion helps.

Regards,
Yavor
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Raddy Rad
Top achievements
Rank 1
answered on 29 Dec 2010, 05:17 PM
But what is the client api that retrieves the column width for a given column index, say.
0
Princy
Top achievements
Rank 2
answered on 30 Dec 2010, 10:19 AM
Hello Raddy,

Try the following  code to get the column width from client side.

Java Script:
var masterTable = $find("<%= RadGrid1.ClientID %>").get_masterTableView();
      alert(masterTable.get_columns()[0].get_element().clientWidth);

Thanks,
Princy.
0
Raddy Rad
Top achievements
Rank 1
answered on 30 Dec 2010, 04:47 PM
Thanks princy! On the reverse, should i resizeColumn to size it back?

In that aspect, i'm getting mixed results - it's resizing as expected if i'm only resizing one column. But when i try to resize more than one column, only the last one gets resized, as if the first few calls didn't get called.

Am i missing anything?

Thanks in advance!
Tags
Grid
Asked by
AndyL
Top achievements
Rank 1
Answers by
Yavor
Telerik team
Raddy Rad
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or