Added custom sizes 100 and 200 to the combobox in item created as shown. Our grid does an ajax postback to query for more data if page size or number changes.
protected
void
partnerGrid_ItemCreated(
object
sender, GridItemEventArgs e)
{
if
(e.Item
is
GridPagerItem)
{
RadComboBox pageSize = (RadComboBox)e.Item.FindControl(
"PageSizeComboBox"
);
RadComboBoxItem rcbItem100 = pageSize.FindItemByText(
"100"
);
RadComboBoxItem rcbItem200 = pageSize.FindItemByText(
"200"
);
if
(rcbItem100 ==
null
)
{
pageSize.Items.Add(
new
RadComboBoxItem(
"100"
));
pageSize.FindItemByText(
"100"
).Attributes.Add(
"ownerTableViewId"
, partnerGrid.MasterTableView.ClientID);
}
if
(rcbItem200 ==
null
)
{
pageSize.Items.Add(
new
RadComboBoxItem(
"200"
));
pageSize.FindItemByText(
"200"
).Attributes.Add(
"ownerTableViewId"
, partnerGrid.MasterTableView.ClientID);
}
pageSize.SelectedValue = partnerGrid.PageSize.ToString();
}
}
Inexplicably, ItemCreated is fired four times when the pagesize is changed. I suppose two are for each pager (even though
it's set to top-only, the bottom pager is still there), but I can't fathom the last two.
Worse, on the 3rd and 4th invocations of ItemCreated, the combobox has remembered the standard three (10, 20, 50) plus whatever
was selected, but has lost the unselected one. So, if the user goes directly to 200, when the grid re-renders
it shows 100 below 200 (as it was added but 200 was already there).
Secondly, on subsequent postbacks, the combobox will not accept a selectedValue of whatever the fifth item is now
and keeps defaulting to 10. The grid's page size is fine, so the query gets the appropriate number of items,
we just show 10 in the pulldown instead of the number they actually chose.
The ajax is really simple:<
telerik:AjaxSetting
AjaxControlID
=
"partnerGrid"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"partnerGrid"
LoadingPanelID
=
"gridLoadingPanel"
/>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
Anytime we do something in the grid, show the loading panel while we're thinking about it. It seems as if
something's wrong in ajax land, but it can't be simpler than that.