This is a migrated thread and some comments may be shown as answers.

Page Size / PageSizes Problem

17 Answers 1452 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Justin
Top achievements
Rank 1
Justin asked on 24 May 2013, 09:27 PM
Hi All,

this is my first post here, but I'm having a problem with the PageSizes setting for a grid.

Here is my markup for the Pager:
<PagerStyle Mode="NextPrevAndNumeric" PageSizeLabelText="Page Size: " PageSizes="{1, 10, 20, 50, 100, 200, 250}" />


And attached is an image showing what this produces (the grid has been removed because of client info).

As you can see, the first and last options are not present in the dropdown.  Why is this?

My second question would be this:  If I wanted (site-wide) to have 10,20, 50, 100, 200 as my page sizes, and 50 as the default...is there a way to do that without modifying all grids in my system individually?

17 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 26 May 2013, 10:11 AM
Hello,

Please create one skin file and add below code line in it.
<telerik:RadGrid  runat="server"  PageSize="50"  AllowPaging="true">        </telerik:RadGrid>

Please check below link to customize page size comboBox.
http://jayeshgoyani.blogspot.in/2012/06/customizing-items-of-radgrid-page-size.html

Thanks,
Jayesh Goyani
0
Justin
Top achievements
Rank 1
answered on 26 May 2013, 07:16 PM
Hi!  Thanks for the answers.

A couple of followups:

1. So the PageSizes property inside the asp does not function correctly?  I need to do it programatically like the blog post outlines?

2. I've done some looking at the skinning documentation (we are just using the default) and I don't see how creating a skin for RadGrid would change the default behavior of the combo box site wide.  Maybe I am just misunderstanding what you mean.

Thanks!
Justin
0
Princy
Top achievements
Rank 2
answered on 27 May 2013, 05:15 AM
Hi Justin,

I suppose you want to programmatically set the page size,please have a look at this code.
C#:
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
   {
       if (e.Item is GridPagerItem)
       {
           RadComboBox PageSizeCombo = (RadComboBox)e.Item.FindControl("PageSizeComboBox");
 
           PageSizeCombo.Items.Clear();
           PageSizeCombo.Items.Add(new RadComboBoxItem("10"));
           PageSizeCombo.FindItemByText("10").Attributes.Add("ownerTableViewId", RadGrid1.MasterTableView.ClientID);
           PageSizeCombo.Items.Add(new RadComboBoxItem("20"));
           PageSizeCombo.FindItemByText("20").Attributes.Add("ownerTableViewId", RadGrid1.MasterTableView.ClientID);
           PageSizeCombo.Items.Add(new RadComboBoxItem("50"));
           PageSizeCombo.FindItemByText("50").Attributes.Add("ownerTableViewId", RadGrid1.MasterTableView.ClientID);
           PageSizeCombo.Items.Add(new RadComboBoxItem("100"));
           PageSizeCombo.FindItemByText("100").Attributes.Add("ownerTableViewId", RadGrid1.MasterTableView.ClientID);
           PageSizeCombo.Items.Add(new RadComboBoxItem("200"));
           PageSizeCombo.FindItemByText("200").Attributes.Add("ownerTableViewId", RadGrid1.MasterTableView.ClientID);
           PageSizeCombo.FindItemByText(e.Item.OwnerTableView.PageSize.ToString()).Selected = true;
       }
   }

ASPX:
<telerik:RadGrid ID="RadGrid1"  AllowPaging="True" PageSize="50" runat="server" OnItemDataBound="RadGrid1_ItemDataBound">
    <PagerStyle PageSizeControlType="RadComboBox"></PagerStyle>
  </telerik:RadGrid>


Thanks
Princy
0
Justin
Top achievements
Rank 1
answered on 28 May 2013, 04:43 PM
Hi Princy,

Thanks for the answer, but the first response already explained (in the blog post) how to do it programatically.  So I don't need that.  What I would really like to know is why the PageSizes attribute doesn't work the way it should.

If you look at the original post I made, you will see that it sort-of works, but it leaves off the first and last options.  Is this intended?  I can't find any real documentation on this attribute.

Thanks,
Justin
0
Princy
Top achievements
Rank 2
answered on 29 May 2013, 09:06 AM
Hello Justin,

The format of writing the PageSize is shown below,try removing the curly braces{..},please try this.

ASPX:
<PagerStyle Mode="NextPrevAndNumeric" PageSizes="1,10,20,30,40,50"/>

Thanks,
Princy
0
Justin
Top achievements
Rank 1
answered on 29 May 2013, 07:39 PM
Hi Princy,

Thank you!  I'm going to give that a try and see what happens.  Now my other question had to do with how to set this up as the default pagesize dropdown for every radgrid in my system.  Someone above mentioned using a skin for this.  How would I use a skin to accomplish that?  

Thanks!
Justin
0
Princy
Top achievements
Rank 2
answered on 30 May 2013, 06:25 AM
Hi Justin,

As far as i know we cant set any skin for pager,but we can set the CSS for that pager combobox.Every skin contains,its own style,so with that, inorder to set color for the pager combobox,we should give CSS.

ASPX:
<telerik:RadGrid ID="RadGrid1" AllowPaging="True" PageSize="10"  Skin="Web20">
  <PagerStyle PageSizeControlType="RadComboBox" > </PagerStyle>
</telerik:RadGrid>

CSS:
div.RadGrid .RadComboBox td
{
    background-color: green;
    background-image: none;
    border: 0 none;
}

Thanks,
Princy
0
Kyle
Top achievements
Rank 1
answered on 13 Jun 2013, 03:55 PM

The PageSizes Attribute is not working for me as well:

 

 

<telerik:RadGrid AutoGenerateColumns="false" ID="rgSearch"

 

 

 

AllowFilteringByColumn="True" AllowPaging ="true" AllowSorting="true"

 

 

 

runat="server" PageSize="50" onneeddatasource="rgSearch_NeedDataSource" Skin="WebBlue" >

 

 

 

 


<
PagerStyle Mode="NextPrevAndNumeric" PageSizeLabelText="Page Size: " PageSizes="5,10,25,50,100,250" />

 

<

 

 

MasterTableView TableLayout="Auto" AllowMultiColumnSorting="true">

 

 

 

<CommandItemSettings ShowExportToExcelButton="true" ShowAddNewRecordButton="false"></CommandItemSettings>

 

 

 

<Columns>
  ...

 

 

 

</Columns>

 

 

 

 

 

 

 

</MasterTableView>

 

 

 

 

 

 

 

<ExportSettings ExportOnlyData="false" OpenInNewWindow="true" HideStructureColumns="true">

 

 

 

 

 

 

 

<Excel Format="Biff" />

 

 

 

 

 

 

 

</ExportSettings>

 

 

 

 

 

 

 

 

</telerik:RadGrid>

 

0
Princy
Top achievements
Rank 2
answered on 14 Jun 2013, 03:48 AM
Hi Kyle,

You have placed the PagerStyle property out of MasterTableView,thats why,it takes the default value.Please set it after the MasterTableView.

ASPX:
<telerik:RadGrid AutoGenerateColumns="false" ID="rgSearch" AllowFilteringByColumn="True"
            AllowPaging="true" AllowSorting="true" runat="server" PageSize="50" Skin="WebBlue">           
      <MasterTableView TableLayout="Auto" AllowMultiColumnSorting="true">
            <PagerStyle Mode="NextPrevAndNumeric" PageSizeLabelText="Page Size: " PageSizes="5,10,25,50,100,250" />
                <CommandItemSettings ShowExportToExcelButton="true" ShowAddNewRecordButton="false" />
            <Columns>
. . . . . . . . .
. . . . . . . . .
            </Columns>
      </MasterTableView>          
</telerik:RadGrid>

Thanks,
Princy
0
Kyle
Top achievements
Rank 1
answered on 14 Jun 2013, 03:32 PM
And just like that, it works!   Couldn't find any examples of this in the demos . . . thanks very much for the help!
0
Kasun
Top achievements
Rank 1
answered on 20 May 2015, 04:56 AM

The PageSizes Attribute is not working for me  

<telerik:RadGrid ID="grdJobList" runat="server" GridLines="None" Skin="Outlook" AllowPaging="true"
                AllowSorting="True" 
                OnNeedDataSource="RadGridStockRecevedStatus_NeedDataSource" PageSize="50"
                AllowFilteringByColumn="True" OnDeleteCommand="grdJobList_DeleteCommand" 
                OnItemCommand="grdJobItem_ItemCommand">
                <GroupingSettings CaseSensitive="false"  />
                <MasterTableView AutoGenerateColumns="False" DataKeyNames="Id,JobType,DepartmentCode"
                    CommandItemDisplay="Top">
                    <PagerStyle Mode="NextPrevAndNumeric" PageSizeLabelText="Page Size: " PageSizes="5,10,25,50,100,250" />
                    <CommandItemTemplate>
                        <asp:Button ID="BtnCSV" runat="server" CssClass="btnGridAddItm" CommandName="ExportToCsv"
                            Text="Export to CSV"></asp:Button>
                    </CommandItemTemplate>
                    <CommandItemSettings ExportToPdfText="Export to Pdf"></CommandItemSettings>
                    <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
                        <HeaderStyle Width="20px"></HeaderStyle>
                    </RowIndicatorColumn>
                    <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">
                        <HeaderStyle Width="20px"></HeaderStyle>
                    </ExpandCollapseColumn>
                    <Columns>

 </Columns>

0
Jayesh Goyani
Top achievements
Rank 2
answered on 20 May 2015, 12:46 PM

Hello Kasun,

It would be nice if you can provide telerik DLL version.

Thanks, 

Jayesh Goyani

0
Sony
Top achievements
Rank 1
answered on 20 Nov 2015, 08:45 AM

http://stackoverflow.com/questions/33822075/cannot-identify-selected-page-in-telerik-grid-i-need-selected-page-to-be-underl

Plz go through the link and and help me

 

 

0
Kiran
Top achievements
Rank 1
answered on 29 Oct 2020, 12:46 PM
Wow. This actually solved my problem. I put the Pagessize in PagerStyle above the mastertable and was wondering why it did not work. It actually matters that the PagerStyle should be placed below the MasterTable View. I hope Radgrid should have thrown an error when setting such properties above the master table view. Anyways, thank you Princy.
0
Vessy
Telerik team
answered on 02 Nov 2020, 05:15 PM

Hi Kiran,

When the PagerStyles is placed outside the MasterTable it takes the default value of the Grid. There are many properties in the Grid that can be set both on Grid and on MasterTable level depending on the scope of the applied value.

You can find more detailed information on this matter here:

https://docs.telerik.com/devtools/aspnet-ajax/controls/grid/structure/radgrid-and-mastertableview-difference#radgrid-and-mastertableview-difference

Regards,
Vessy
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Kiran
Top achievements
Rank 1
answered on 02 Nov 2020, 05:17 PM

Hi Vessy,

Now I understand. Thank you for the information.

0
Vessy
Telerik team
answered on 03 Nov 2020, 07:19 AM

Hi,

You are welcome, Kiran, I am glad my reply shed some light on this matter.

Regards,
Vessy
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
Grid
Asked by
Justin
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Justin
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Kyle
Top achievements
Rank 1
Kasun
Top achievements
Rank 1
Sony
Top achievements
Rank 1
Kiran
Top achievements
Rank 1
Vessy
Telerik team
Share this question
or