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

NumericPager not working but Next/Prev works

1 Answer 35 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Patrick
Top achievements
Rank 1
Patrick asked on 06 Jun 2012, 08:44 PM
I have a RadGrid setup and everything on it works great except for my Numeric Pager.  I placed my pager in my PagerTemplate like so:

<asp:Panel runat="server" ID="NumericPagerPlaceHolder"  />

And then in my code behind, here is how I set it up:

protected void HandleOnItemDataBound(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridPagerItem)
            {
                var gridPager = e.Item as GridPagerItem;
                var numericPagerControl = gridPager.GetNumericPager();
 
                var placeHolder = gridPager.FindControl("NumericPagerPlaceHolder");
                placeHolder.Controls.Add(numericPagerControl);
            }
        }

The numeric pager is getting setup properly but when I click on a page number, it does a very fast postback and then the numeric pager disappears completely.  I feel like I am missing a step where I should be binding and event.  All the Google and forum searches I have done haven't turned anything up.  The only thing I found was including this JavaScript:

<telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
 
        <script type="text/javascript">
            var tableView = null;
            function pageLoad(sender, args) {
                tableView = $find("<%= TransactionsGrid.ClientID %>").get_masterTableView();
            }
 
            function changePage(argument) {
                tableView.page(argument);
            }
        </script>
 
    </telerik:RadScriptBlock>

But still nothing.  I've even tried setting up an event handler for OnPageIndexChanged but that didn't work either.  Any help would be appreciated.

1 Answer, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 07 Jun 2012, 06:09 AM
Hello Patrick,

Try adding the same code in ItemCreated event which worked as expected.
C#:
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
{
     if (e.Item is GridPagerItem)
     {
       var gridPager = e.Item as GridPagerItem;
       var numericPagerControl = gridPager.GetNumericPager();
        var placeHolder = gridPager.FindControl("NumericPagerPlaceHolder");
        placeHolder.Controls.Add(numericPagerControl);
      }
}

Also try setting AlwaysVisible property as true.
aspx:
<PagerStyle AlwaysVisible="true" Mode="NumericPages" />

Thanks,
Shinu.
Tags
Grid
Asked by
Patrick
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or