I wanted more values inside the Grid pagesizer (instead of 10,20,50), so i wrote the following code (partly from the web)
public static void ConfigurePageSizer(GridPagerItem pagerItem)
{
RadComboBox _pageSizeComboBox = (RadComboBox) pagerItem.FindControl("PageSizeComboBox");
_pageSizeComboBox.Items.Clear();
int[] _pageSize = new [] {10,20,50,100,250,500,750,1000};
foreach (int _Size in _pageSize)
{
RadComboBoxItem _item = new RadComboBoxItem();
_item.Text = _Size.ToString(CultureInfo.InvariantCulture);
_item.Value = _Size.ToString(CultureInfo.InvariantCulture);
_item.Attributes.Add("ownerTableViewId", pagerItem.OwnerTableView.ClientID);
_pageSizeComboBox.Items.Add(_item);
}
}
and then called it from : ....
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
{
if (e.Item is GridPagerItem)
{
GridHelper.ConfigurePageSizer((GridPagerItem)e.Item);
}
}
But ... the problem is ... the Grid page size combobox behaviour is now that is lost track of the current selected value, it always selects the first (10)
Please advice and/or Tips
Kind regards,
Hugo
public static void ConfigurePageSizer(GridPagerItem pagerItem)
{
RadComboBox _pageSizeComboBox = (RadComboBox) pagerItem.FindControl("PageSizeComboBox");
_pageSizeComboBox.Items.Clear();
int[] _pageSize = new [] {10,20,50,100,250,500,750,1000};
foreach (int _Size in _pageSize)
{
RadComboBoxItem _item = new RadComboBoxItem();
_item.Text = _Size.ToString(CultureInfo.InvariantCulture);
_item.Value = _Size.ToString(CultureInfo.InvariantCulture);
_item.Attributes.Add("ownerTableViewId", pagerItem.OwnerTableView.ClientID);
_pageSizeComboBox.Items.Add(_item);
}
}
and then called it from : ....
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
{
if (e.Item is GridPagerItem)
{
GridHelper.ConfigurePageSizer((GridPagerItem)e.Item);
}
}
But ... the problem is ... the Grid page size combobox behaviour is now that is lost track of the current selected value, it always selects the first (10)
Please advice and/or Tips
Kind regards,
Hugo
6 Answers, 1 is accepted
0
Hi Hugo,
The forum thread below demonstrates how you can achieve the desired functionality:
http://www.telerik.com/community/forums/aspnet-ajax/grid/changing-page-size-in-combo-box.aspx
Greetings,
Pavlina
the Telerik team
The forum thread below demonstrates how you can achieve the desired functionality:
http://www.telerik.com/community/forums/aspnet-ajax/grid/changing-page-size-in-combo-box.aspx
Greetings,
Pavlina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Hugo
Top achievements
Rank 1
answered on 12 Mar 2012, 08:51 AM
Hi Pavlina ,
Like dexter (see the thread) the solution doesnot work for me, when is do a rebind the pageSizer combobox selects the default value.
Why does the combobox loose selection when extending the values? That is wierd, man!
In my opinion it should be very simply to extend the combox.
Can you tell me how to extend the default page size combobox that works and interact with the radgrid, without doing a lot of coding myself, like keeping track of the curent selection myself by means of a session[selection]
Kind regards,
Hugo
Like dexter (see the thread) the solution doesnot work for me, when is do a rebind the pageSizer combobox selects the default value.
Why does the combobox loose selection when extending the values? That is wierd, man!
In my opinion it should be very simply to extend the combox.
Can you tell me how to extend the default page size combobox that works and interact with the radgrid, without doing a lot of coding myself, like keeping track of the curent selection myself by means of a session[selection]
Kind regards,
Hugo
0
Hello Hugo,
I am attaching a sample working project which handles the desired functionality. Please give it a try and let me know if it works for you and what is the difference in your case.
Greetings,
Pavlina
the Telerik team
I am attaching a sample working project which handles the desired functionality. Please give it a try and let me know if it works for you and what is the difference in your case.
Greetings,
Pavlina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Hugo
Top achievements
Rank 1
answered on 21 Mar 2012, 09:34 AM
The line of code that solve the problem was:
_pageSizeComboBox.Items.FindItemByValue(_grid.PageSize.ToString(CultureInfo.InvariantCulture)).Selected = true;
So it seems RadGrid.pagesize keeps current page size (which is undocumented).
So my final function :
public static void ConfigurePageSizer(GridPagerItem pagerItem)
{
RadComboBox _pageSizeComboBox = (RadComboBox) pagerItem.FindControl("PageSizeComboBox");
_pageSizeComboBox.Items.Clear();
int[] _pageSize = new [] {10,20,50,100,250,500,750,1000};
foreach (int _size in _pageSize)
{
string _value = _size.ToString(CultureInfo.InvariantCulture);
RadComboBoxItem _item = new RadComboBoxItem(_value, _value);
_item.Attributes.Add("ownerTableViewId", pagerItem.OwnerTableView.ClientID);
if (_pageSizeComboBox.Items.FindItemByValue(_value) == null)
{
_pageSizeComboBox.Items.Add(_item);
}
}
RadGrid _grid = pagerItem.OwnerTableView.OwnerGrid;
_pageSizeComboBox.Items.FindItemByValue(_grid.PageSize.ToString(CultureInfo.InvariantCulture)).Selected = true;
_grid.Focus();
}
_pageSizeComboBox.Items.FindItemByValue(_grid.PageSize.ToString(CultureInfo.InvariantCulture)).Selected = true;
So it seems RadGrid.pagesize keeps current page size (which is undocumented).
So my final function :
public static void ConfigurePageSizer(GridPagerItem pagerItem)
{
RadComboBox _pageSizeComboBox = (RadComboBox) pagerItem.FindControl("PageSizeComboBox");
_pageSizeComboBox.Items.Clear();
int[] _pageSize = new [] {10,20,50,100,250,500,750,1000};
foreach (int _size in _pageSize)
{
string _value = _size.ToString(CultureInfo.InvariantCulture);
RadComboBoxItem _item = new RadComboBoxItem(_value, _value);
_item.Attributes.Add("ownerTableViewId", pagerItem.OwnerTableView.ClientID);
if (_pageSizeComboBox.Items.FindItemByValue(_value) == null)
{
_pageSizeComboBox.Items.Add(_item);
}
}
RadGrid _grid = pagerItem.OwnerTableView.OwnerGrid;
_pageSizeComboBox.Items.FindItemByValue(_grid.PageSize.ToString(CultureInfo.InvariantCulture)).Selected = true;
_grid.Focus();
}
0
Spiros
Top achievements
Rank 1
answered on 10 Sep 2014, 06:14 AM
Hi Shinu.
I have a grid that is being filled from Need_DataSource event.
In my grid i have 20 records , and when I select the (50) PageSizeComboBox , the PageSizeComboBox
is lost and i can not select any more.. Can you please tell me how i can fix this issue ?
Thanks in advance.
Spiros
I have a grid that is being filled from Need_DataSource event.
In my grid i have 20 records , and when I select the (50) PageSizeComboBox , the PageSizeComboBox
is lost and i can not select any more.. Can you please tell me how i can fix this issue ?
Thanks in advance.
Spiros
0
Hi,
To make the pager always visible, even when the items are less than the selected pagesize, you should set AlwaysVisible property to true as shown below:
Regards,
Pavlina
Telerik
To make the pager always visible, even when the items are less than the selected pagesize, you should set AlwaysVisible property to true as shown below:
<
telerik:RadGrid
ID
=
"RadGrid1"
AllowPaging
=
"true"
runat
=
"server"
PageSize
=
"10"
>
<
MasterTableView
>
<
PagerStyle
Mode
=
"NextPrevNumericAndAdvanced"
AlwaysVisible
=
"true"
/>
..................................
Regards,
Pavlina
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.