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

Pager disappears in the RadGrid

14 Answers 576 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dmitry
Top achievements
Rank 1
Dmitry asked on 15 Jul 2009, 08:15 PM
Hello. I need to "expand" the default choices of "10/20/50" for page size to "10/20/50/100/200../1000" and I need to re-bind the grid as soon as the user selects the desired page size.

I implemented the following code:

  protected void rgURL_Load(object sender, EventArgs e)
  {
    GridItem[] pagers = rgURL.MasterTableView.GetItems(GridItemType.Pager);

    foreach (GridItem pager in pagers)
    {
      RadComboBox comboBox = (RadComboBox)pager.FindControl("PageSizeComboBox");

      comboBox.SelectedIndexChanged += delegate(object _source, RadComboBoxSelectedIndexChangedEventArgs _e)
      {
        rgURL.MasterTableView.PageSize = Convert.ToInt32(_e.Value);
        rgURL.Rebind();

        //does not help
        //pager.Visible = true;
      };
    }
  }
  protected void rgURL_PreRender(object sender, EventArgs e)
  {
    GridItem[] pagers = rgURL.MasterTableView.GetItems(GridItemType.Pager);

    foreach (GridItem pager in pagers)
    {
      RadComboBox comboBox = (RadComboBox)pager.FindControl("PageSizeComboBox");

      comboBox.Items.Clear();

      comboBox.Items.Add(new RadComboBoxItem("10", "10"));
      comboBox.Items.Add(new RadComboBoxItem("20", "20"));
      comboBox.Items.Add(new RadComboBoxItem("50", "50"));
      comboBox.Items.Add(new RadComboBoxItem("100", "100"));
      comboBox.Items.Add(new RadComboBoxItem("200", "200"));
      comboBox.Items.Add(new RadComboBoxItem("300", "300"));
      comboBox.Items.Add(new RadComboBoxItem("400", "400"));
      comboBox.Items.Add(new RadComboBoxItem("500", "500"));
      comboBox.Items.Add(new RadComboBoxItem("1000", "1000"));

      comboBox.Items.FindItemByValue(URLGridPageSize.ToString()).Selected = true;

      comboBox.DropDownWidth = Unit.Pixel(60);
      comboBox.AutoPostBack = true;

        //does not help
        //pager.Visible = true;
    }
  }


This works fine until the newly selected page size is greater than the number of rows in the grid. At that point the pager disappears and I cannot make it appear again. I mean, if the grid contains 70 items and page size is 20 - i would see the pager that says I have 4 pages (20 + 20 + 20 + 10). If I then select "100" as a new page size - the grid will show all 70 items on the same page and the pager at this point will disappear.

What do I need to prevent it from disappearing? I'm using Q1 2009 version of controls.

P.S. I was trying to put the code in _ItemDataBound event (as were suggested in the other code) but in than case "SelectedIndexChanged" event would not fire.

Thanks,
Dmitry

14 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 16 Jul 2009, 05:14 AM
Hello Dimitry,

You can try setting the PagerStyle>AlwaysVisible property ro true, so that the pager is always a visible:
 <telerik:RadGrid ID="RadGrid1" AllowPaging="true" PageSize="5" runat="server" OnNeedDataSource="RadGrid1_NeedDataSource"
     <MasterTableView>                     
          <PagerStyle AlwaysVisible="true"/> 

Thanks
Princy.
0
Dmitry
Top achievements
Rank 1
answered on 16 Jul 2009, 03:15 PM
Princy, thanks a lot! It helped.
0
Rick Borage
Top achievements
Rank 1
answered on 03 May 2010, 11:30 PM
The AlwaysVisible property did not fix this for me.  It still disappears if I have 11 items and set the page size to 20.

Any advice?

Rick
0
Iana Tsolova
Telerik team
answered on 04 May 2010, 06:56 AM
Hello Rick,

Try updating to the latest version of RadControls for ASP.NET AJAX - Q1 2010 SP1 and see if the AlwaysVisible property works then. You can also see if setting the MasterTableView-PagerStyle-AlwaysVisible instead of the RadGrid's one makes any difference.

Regards,
Iana
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
Rick Borage
Top achievements
Rank 1
answered on 04 May 2010, 03:41 PM
Thanks Iana.

I should have included my version.  My version says Q1 2010 so I guess maybe I don't have the service pack?  I'll have to look into that.

Settng the property on the MasterTableView did work however.  Thanks again.
0
Steve
Top achievements
Rank 1
answered on 09 Aug 2011, 09:48 PM
I set the AlwaysVisible property on the MasterTableView, but I also set the Position to be Top and Bottom. When the PageSize is greater than the record count and there is only 1 page of data (PageSize is 10, but 4 records are returned) the pager only displays at the bottom. I would like the Pager to either display top and bottom OR allow for the section where the pager resides to be available to the user to display page count and record count (4 records).

How can I provide this? It seems like "something is missing" when the pager doesnt display in with records less than the page size.

Thanks,

0
Andrey
Telerik team
answered on 15 Aug 2011, 08:39 AM
Hi Steve,

I have made a sample project that works on my end, please give it a try and let me know if it works on your end.

Regards,
Andrey
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
Sulabh
Top achievements
Rank 1
answered on 16 Sep 2013, 08:51 AM
i want to show pager on rad grid.. i already set PagerStyle AlwaysVisible="True" ... but still pager not show ... why..?
0
Konstantin Dikov
Telerik team
answered on 19 Sep 2013, 08:38 AM
Hello Sulabh,

Could you please ensure that you are setting the "AllowPaging" property of the RadGrid to "true", since you need both of the properties (including "PagerStyle-AlwaysVisible") in order to show the pager at all times.

I have prepared a sample project with "AllowPaging" and "PagerStyle-AlwaysVisible" properties set to "true". Please test it on your side and see if it works as expected on your side too.

Hope that helps.

 

Regards,
Konstantin Dikov
Telerik
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 the blog feed now.
0
Álvaro
Top achievements
Rank 1
answered on 14 Oct 2013, 11:35 AM
Hello,

I've the same problem. I have some aspx pages with RadGrid control, but there is a problem with a specific RadGrid. It doesn't show pager control. My page size is "10" and I have at least 3000 records in grid.

<telerik:RadGrid ID="gvActuaciones" runat="server" AutoGenerateColumns="False"
            PageSize="10" PagerStyle-Font-Size="Medium" AllowPaging="true"
               AllowSorting="true" AllowFilteringByColumn="true"
            OnNeedDataSource="gvActuaciones_NeedDataSource" ShowFooter="false"
               OnItemDataBound="gvActuaciones_ItemDataBound"
            OnSelectedIndexChanged="gvActuaciones_SelectedIndexChanged"
               OnDeleteCommand="gvActuaciones_DeleteCommand"
            OnEditCommand="gvActuaciones_EditCommand"
            OnRowDataBound="gvActuaciones_RowDataBound" OnPageIndexChanged="gvActuaciones_PageIndexChanged"
               EnableAjaxSkinRendering="true" Skin="Metro" EnableEmbeddedSkins="true"
            EnableLinqExpressions="False" EnableViewState="true"
            FilterItemStyle-CssClass="filaFiltrado" CssClass="gridDatos">
            <ClientSettings>
                <Scrolling AllowScroll="true" UseStaticHeaders="true" SaveScrollPosition="true" ></Scrolling>
            </ClientSettings>
            <GroupingSettings CaseSensitive="false"></GroupingSettings>
            <MasterTableView TableLayout="Fixed" Width="100%" AllowNaturalSort="false" PagerStyle-AlwaysVisible="true" >
                <Columns>
 
                           .......
 
                </Columns>
            </MasterTableView>
</telerik:RadGrid>

Is there any reason for this behaviour? i had 2013.2.611 version and I've just updated to 2013.2 717, but It doesn't work.

Thanks a lot
0
Konstantin Dikov
Telerik team
answered on 15 Oct 2013, 01:11 PM
Hi Álvaro,

I have tested the provided code snippet and I was unable to observe any issues with the pager, so I could guess that you are doing something in the code behind that prevents the pager from showing.

Could you please refer to the attached sample page to see if it works as expected on your side and what differs from your project.

Hope that helps.

 

Regards,
Konstantin Dikov
Telerik
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 the blog feed now.
0
Álvaro
Top achievements
Rank 1
answered on 18 Oct 2013, 08:40 AM
Thanks Konstantin for your response.

I've solved my problem but I don't know how!!

Can the property "AllowNaturalSort" to "false" hide the pager table?

I have restored old versions from my TFS server and I have changed them step by step until to get similar versions.
There is only a big difference now, between the code that didn't work properly and the actual code.
I've removed the property "AllowNaturalSort" from MasterTableView

<MasterTableView TableLayout="Fixed" Width="100%" AllowNaturalSort="false" >

Thanks again.
Regards
0
Konstantin Dikov
Telerik team
answered on 22 Oct 2013, 11:01 AM
Hello Álvaro,

As you could see from the attached project, the "AllowNaturalSort" property is set to false. Actually, no changes were made from the provided code snippet and I was unable to observe issues with the pager.

Could you elaborate if the attached sample page within my previous post is working as expected on your side or is the issue still present?

Furthermore, I will be really thankful if you could provide a sample page that replicates this behavior with our latest version, so that we could inspect it locally, and if such issue exist, to provide a fix for it in future releases.

Looking forward to your reply.

 

Regards,
Konstantin Dikov
Telerik
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 the blog feed now.
0
Álvaro
Top achievements
Rank 1
answered on 22 Oct 2013, 02:24 PM
Hello Konstantin,

your code works properly. Finally, I've found the problem. It wasn't 'AllowNaturalSort' attribute.
On 'ItemDataBound' event of the grid, I had the following line, for each item:

protected void gvActuaciones_ItemDataBound(object sender, GridItemEventArgs e)
{
         e.Item.Edit = false;
         .........
}

When I deleted this line, the pager suddenly showed up. I don't know why this line is related to pager dissapears.

Thank you very much for your help.
Regards
Tags
Grid
Asked by
Dmitry
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Dmitry
Top achievements
Rank 1
Rick Borage
Top achievements
Rank 1
Iana Tsolova
Telerik team
Steve
Top achievements
Rank 1
Andrey
Telerik team
Sulabh
Top achievements
Rank 1
Konstantin Dikov
Telerik team
Álvaro
Top achievements
Rank 1
Share this question
or