I'm getting some very odd behavior on my radgrid when I call resizetofit after settings columns Display=false from the code behind. A lot of white space is left on the first call and on subsequent calls the grid continues to shrink and be set to more readable dimensions. The grid is very large (105 columns) and I'm using a checkbox list to allow users to select which columns they want visible which removes excess columns using radGrid.MasterTableView.Columns[i].Display = false; Currently I'm resolving the issue by wrapping the script called afterwards in a loop so it runs 3 times, but it continues to shrink long after even 3 calls. Depending on how many rows are removed it continues to shrink (at a reducing rate) up to 8 calls afterwards. Javascript and grid markup below:
<
script
>
function resize() {
var grid = $find("<%= gridAgents.ClientID %>");
var columns = grid.get_masterTableView().get_columns();
for (var i = 0; i <
columns.length
; i++) {
columns[i].resizeToFit();
}
}
</script>
<
telerik:RadGrid
ID
=
"gridAgents"
runat
=
"server"
AllowPaging
=
"True"
AllowSorting
=
"True"
OnNeedDataSource
=
"gridAgents_NeedDataSource"
ShowGroupPanel
=
"True"
OnEditCommand
=
"gridAgents_EditCommand"
OnUpdateCommand
=
"gridAgents_UpdateCommand"
OnDeleteCommand
=
"gridAgents_DeleteCommand"
OnCancelCommand
=
"gridAgents_CancelCommand"
OnInsertCommand
=
"gridAgents_InsertCommand"
OnItemUpdated
=
"gridAgents_ItemUpdated"
OnItemDeleted
=
"gridAgents_ItemDeleted"
OnItemInserted
=
"gridAgents_ItemInserted"
AutoGenerateColumns
=
"false"
>
<
HeaderStyle
BorderColor
=
"LightGray"
BorderWidth
=
"1px"
/>
<
GroupingSettings
CollapseAllTooltip
=
"Collapse all groups"
/>
<
ClientSettings
AllowDragToGroup
=
"True"
>
<
Resizing
AllowColumnResize
=
"true"
ResizeGridOnColumnResize
=
"true"
AllowResizeToFit
=
"true"
/>
</
ClientSettings
>
<
MasterTableView
AutoGenerateColumns
=
"False"
CommandItemDisplay
=
"Top"
>
<
Columns
>
<
telerik:GridEditCommandColumn
>
</
telerik:GridEditCommandColumn
>
<
telerik:GridButtonColumn
ButtonType
=
"ImageButton"
CommandName
=
"Delete"
Text
=
"Delete"
UniqueName
=
"DeleteColumn"
ConfirmText
=
"Delete record?"
>
</
telerik:GridButtonColumn
>
//103 Bound/Template columns
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>