Nirnay Bansal
Top achievements
Rank 1
Nirnay Bansal
asked on 27 Aug 2010, 05:53 PM
I added one extra entry in PageSizeComboBox of Grid paging control on (v2010.1.628.40)
{
}
and with (becasue I want to always show Page style with PageSizeComboBox even there is only one page, so that user can use PageSizeComboBox)
It is working fine and I can see my "All" option on the page.
But when I select this option, page postbacks, it display me all the rows correctly, but appending one more entry in PageSizeComboBox and the Text of that entry is "2147483647".
This looks like a bug, How can I stop RadGrid to append this extra entry?
Thanks!
Nirnay
GridItemCreated(
object source, GridItemEventArgs e)
{
if
(e.Item is GridPagerItem)
{
GridPagerItem pagerItem = (GridPagerItem)e.Item;
RadComboBox PageSizeComboBox = (RadComboBox)pagerItem.FindControl("PageSizeComboBox");
// Create a new item for showing All
RadComboBoxItem item = new RadComboBoxItem("All", int.MaxValue.ToString());
item.Attributes.Add(
"ownerTableViewId", e.Item.OwnerTableView.ClientID);
PageSizeComboBox.Items.Add(item);
}
}
and with (becasue I want to always show Page style with PageSizeComboBox even there is only one page, so that user can use PageSizeComboBox)
<
PagerStyle AlwaysVisible="true" />
It is working fine and I can see my "All" option on the page.
But when I select this option, page postbacks, it display me all the rows correctly, but appending one more entry in PageSizeComboBox and the Text of that entry is "2147483647".
This looks like a bug, How can I stop RadGrid to append this extra entry?
Thanks!
Nirnay
7 Answers, 1 is accepted
0
Hello Nirnay Bansal,
To workaround the described behavior you can modify you ItemCreated event handler like this:
I hope this helps.
Greetings,
Martin
the Telerik team
To workaround the described behavior you can modify you ItemCreated event handler like this:
protected
void
RadGrid1_ItemCreated(
object
sender, Telerik.Web.UI.GridItemEventArgs e)
{
if
(e.Item
is
GridPagerItem)
{
GridPagerItem item = e.Item
as
GridPagerItem;
RadComboBox combo = item.FindControl(
"PageSizeComboBox"
)
as
RadComboBox;
RadComboBoxItem newItem = combo.Items.FindItemByValue(
int
.MaxValue.ToString());
if
(newItem ==
null
)
{
RadComboBoxItem citem =
new
RadComboBoxItem(
"All"
,
int
.MaxValue.ToString());
citem.Attributes.Add(
"ownerTableViewId"
, e.Item.OwnerTableView.ClientID);
combo.Items.Add(citem);
}
else
{
newItem.Text =
"All"
;
}
}
}
I hope this helps.
Greetings,
Martin
the Telerik team
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Public Issue Tracking
system and vote to affect the priority of the items
0
Nirnay Bansal
Top achievements
Rank 1
answered on 02 Sep 2010, 03:53 PM
Hi Martin,
The workaround works and I can see my desired values in dropdown now : 10,20,50,All.
But now I am in another problem due to this workaround.
I am having total 44 Values in RadGrid,
1. with Page size=10, I can see 5 pages.
2. with Page size=20, I can see 3 pages.
3. with Page size=50, I can see 1 page. (with left bottom button "|<" "<" 1 ">" ">|", and at right bottom "44 items in 1 pages")
and all the four button "|<" "<" ">" ">|" are disabled. NOTE: number 1 in between 2 button
But when I sellect All, I can see 1 Page. (with left bottom button "|<" "<" ">" ">|", and at right bottom "44 items in 0 pages")
and all the four button "|<" "<" ">" ">|" are "enabled". NOTE: number is absent in between 2 buttons this time.
On clicking on any button, we are getting errors.
Please suggest!
Nirnay
The workaround works and I can see my desired values in dropdown now : 10,20,50,All.
But now I am in another problem due to this workaround.
I am having total 44 Values in RadGrid,
1. with Page size=10, I can see 5 pages.
2. with Page size=20, I can see 3 pages.
3. with Page size=50, I can see 1 page. (with left bottom button "|<" "<" 1 ">" ">|", and at right bottom "44 items in 1 pages")
and all the four button "|<" "<" ">" ">|" are disabled. NOTE: number 1 in between 2 button
But when I sellect All, I can see 1 Page. (with left bottom button "|<" "<" ">" ">|", and at right bottom "44 items in 0 pages")
and all the four button "|<" "<" ">" ">|" are "enabled". NOTE: number is absent in between 2 buttons this time.
On clicking on any button, we are getting errors.
Please suggest!
Nirnay
0
Hello Nirnay Bansal,
Since RadGrid1.CurrentPageIndex property is of type int, it is not expected to store values greater than int.MaxValue. Based on that I would suggest that your "All" item has a value equal to the actual maximum number of records:
I hope this helps.
Regards,
Martin
the Telerik team
Since RadGrid1.CurrentPageIndex property is of type int, it is not expected to store values greater than int.MaxValue. Based on that I would suggest that your "All" item has a value equal to the actual maximum number of records:
protected
void
RadGrid1_ItemCreated(
object
sender, Telerik.Web.UI.GridItemEventArgs e)
{
if
(e.Item
is
GridPagerItem)
{
GridPagerItem item = e.Item
as
GridPagerItem;
RadComboBox combo = item.FindControl(
"PageSizeComboBox"
)
as
RadComboBox;
RadComboBoxItem newItem = combo.Items.FindItemByValue(item.Paging.DataSourceCount.ToString());
if
(newItem ==
null
)
{
RadComboBoxItem citem =
new
RadComboBoxItem(
"All"
, item.Paging.DataSourceCount.ToString());
citem.Attributes.Add(
"ownerTableViewId"
, e.Item.OwnerTableView.ClientID);
combo.Items.Add(citem);
}
else
{
newItem.Text =
"All"
;
}
}
}
I hope this helps.
Regards,
Martin
the Telerik team
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Public Issue Tracking
system and vote to affect the priority of the items
0
Asok
Top achievements
Rank 1
answered on 28 Feb 2011, 07:23 AM
Hello Martin,
I have a similar requirement to add "ALL" option to my RadGrid Page Size combo. I want the options 50,100,150,ALL. I did exactly the same way as you suggested. But the problem is when I select "ALL" option it is returning an error "Input string was not in correct format". So I did remove the "ALL" and replaced it with the actual maximum number of records. Then it is working. What could be wrong from my end when I am adding "ALL" is throwing error?
I am using the Telerik 2009.1.402.0 version.
Regards,
Asok
I have a similar requirement to add "ALL" option to my RadGrid Page Size combo. I want the options 50,100,150,ALL. I did exactly the same way as you suggested. But the problem is when I select "ALL" option it is returning an error "Input string was not in correct format". So I did remove the "ALL" and replaced it with the actual maximum number of records. Then it is working. What could be wrong from my end when I am adding "ALL" is throwing error?
I am using the Telerik 2009.1.402.0 version.
Regards,
Asok
0
Hello Asok,
Indeed the reported problem is observed in the 2009.1.402 version of the product. The issue is fixed in the 2009 Q1 SP2 (2009.1.527) release of the controls. My suggestion is to upgrade to this or later version and verify whether the problem still exists.
If upgrading is not an option for you, another approach you can try is demonstrated in the code bellow:
I hope this helps.
Kind regards,
Martin
the Telerik team
Indeed the reported problem is observed in the 2009.1.402 version of the product. The issue is fixed in the 2009 Q1 SP2 (2009.1.527) release of the controls. My suggestion is to upgrade to this or later version and verify whether the problem still exists.
If upgrading is not an option for you, another approach you can try is demonstrated in the code bellow:
protected
void
RadGrid1_ItemCreated(
object
sender, Telerik.Web.UI.GridItemEventArgs e)
{
if
(e.Item
is
GridPagerItem)
{
GridPagerItem item = e.Item
as
GridPagerItem;
RadComboBox combo = item.FindControl(
"PageSizeComboBox"
)
as
RadComboBox;
combo.AutoPostBack =
true
;
combo.SelectedIndexChanged +=
new
RadComboBoxSelectedIndexChangedEventHandler(combo_SelectedIndexChanged);
}
}
void
combo_SelectedIndexChanged(
object
o, RadComboBoxSelectedIndexChangedEventArgs e)
{
RadGrid1.PageSize =
int
.Parse((o
as
RadComboBox).SelectedValue);
RadGrid1.Rebind();
}
protected
void
RadGrid1_ItemDataBound(
object
sender, GridItemEventArgs e)
{
if
(e.Item
is
GridPagerItem)
{
GridPagerItem item = e.Item
as
GridPagerItem;
RadComboBox combo = item.FindControl(
"PageSizeComboBox"
)
as
RadComboBox;
RadComboBoxItem newItem = combo.Items.FindItemByValue(item.Paging.DataSourceCount.ToString());
if
(newItem ==
null
)
{
RadComboBoxItem citem =
new
RadComboBoxItem(
"All"
, item.Paging.DataSourceCount.ToString());
combo.Items.Add(citem);
}
else
{
newItem.Text =
"All"
;
}
combo.SelectedValue = RadGrid1.MasterTableView.PageSize.ToString();
}
}
I hope this helps.
Kind regards,
Martin
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
Rohan
Top achievements
Rank 1
answered on 07 Aug 2012, 03:04 PM
Hi Martin ,
To add custom option in Rad grid page size drop down such as "All". after the clicking to "All" ,it appending the total rad grid size to page size drop down .. how can i remove this ?
To add custom option in Rad grid page size drop down such as "All". after the clicking to "All" ,it appending the total rad grid size to page size drop down .. how can i remove this ?
0
Hello Rohan,
I am attaching a sample project that works as expected with the latest version of RadControls (2012.2.724).
I hope this helps.
Regards,
Martin
the Telerik team
I am attaching a sample project that works as expected with the latest version of RadControls (2012.2.724).
I hope this helps.
Regards,
Martin
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.