Please refer to the attached sample project and select a new value in the drop down.
Workaround: change the PageSize in the RadDropDownListElement.PopupClosed event:
public sealed class PageSizeDropdownHeaderCellElement : GridHeaderCellElement
{
public PageSizeDropdownHeaderCellElement(GridViewColumn col, GridRowElement row) : base(col, row)
{
TextAlignment = ContentAlignment.TopCenter;
Alignment = ContentAlignment.TopCenter;
}
private RadDropDownListElement _dropDownListElement;
protected override void CreateChildElements()
{
base.CreateChildElements();
_dropDownListElement = new RadDropDownListElement();
if (_dropDownListElement != null && _dropDownListElement.DataSource == null)
{
_dropDownListElement = new RadDropDownListElement();
_dropDownListElement.BindingContext = new BindingContext();
_dropDownListElement.DropDownStyle = Telerik.WinControls.RadDropDownStyle.DropDownList;
_dropDownListElement.Items.Clear();
_dropDownListElement.Items.Add(new RadListDataItem("10", 10) { Selected = true });
_dropDownListElement.Items.Add(new RadListDataItem("25", 25));
_dropDownListElement.Items.Add(new RadListDataItem("50", 50));
_dropDownListElement.Items.Add(new RadListDataItem("100", 100));
_dropDownListElement.Items.Add(new RadListDataItem("All", -1));
_dropDownListElement.Margin = new Padding(15, 0, 0, 0);
_dropDownListElement.StretchHorizontally = true;
_dropDownListElement.NotifyParentOnMouseInput = false;
_dropDownListElement.Popup.MouseClick += Popup_MouseClick;
_dropDownListElement.PopupClosed += _dropDownListElement_PopupClosed;
this.Children.Add(_dropDownListElement);
}
}
RadListVisualItem elementUnderMouse;
private void Popup_MouseClick(object sender, MouseEventArgs e)
{
elementUnderMouse = _dropDownListElement.Popup.ElementTree.GetElementAtPoint(e.Location) as RadListVisualItem;
}
private void _dropDownListElement_PopupClosed(object sender, RadPopupClosedEventArgs args)
{
if (elementUnderMouse == null)
{
return;
}
if (_dropDownListElement.SelectedIndex == -1)
return;
var pageSize = Convert.ToInt32(elementUnderMouse.Data.Value);
if (pageSize == -1)
{
pageSize = GridControl.RowCount;
}
else
{
pageSize = pageSize <= GridControl.RowCount ? pageSize : GridControl.RowCount;
}
this.RowInfo.Tag = pageSize;
GridControl.PageSize = pageSize;
elementUnderMouse = null;
}
protected override void SetContentCore(object value)
{
if (_dropDownListElement != null && this.RowInfo.Tag != null)
{
this._dropDownListElement.SelectedValue = (int)this.RowInfo.Tag;
}
}
public override bool IsCompatible(GridViewColumn data, object context)
{
return data is ActionColumn && context is GridTableHeaderRowElement;
}
protected override Type ThemeEffectiveType
{
get
{
return typeof(GridHeaderCellElement);
}
}
}