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

Trigger a page index change from client from outside of PagerTemplate?

2 Answers 22 Views
Grid
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 11 Nov 2013, 06:38 PM
Hi,

Is there a way to do this from outside the bottom of the Grid's PagerTemplate?  Say from a dropdown of page numbers or a Next/Previous button elsewhere on the page.  For instance, my grid's page "1" has the following script reference when I mouse over it...

javascript:__doPostBack('ctl00$PageContent$MySearchControl$grdSearchResult$ctl00$ctl03$ctl01$ctl01','')


I know there the GetPostBackEventReference method, but I'm not sure how to use it with my Grid's pager.

Thanks, Dave.

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 12 Nov 2013, 01:48 PM
Hi David,

You can use the fireCommand, which triggers specific command for the grid when executed. Please try the following code snippet to perform Prev/Next paging action.

ASPX:
<telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="true" . . >
    <MasterTableView >
        <Columns>
            . . . . . .
        </Columns>
    </MasterTableView>
</telerik:RadGrid>
<asp:Button ID="PrevBtn" runat="server" Text="Prev" OnClientClick="PrevClick();return false;" />
<asp:Button ID="NextBtn" runat="server" Text="Next" OnClientClick="NextClick();return false;" />

JS:
<script type="text/javascript">
    function PrevClick() {
        var masterTable = $find("<%= RadGrid1.ClientID %>").get_masterTableView();
        masterTable.fireCommand("Page", "Prev");
    }
    function NextClick() {
        var masterTable = $find("<%= RadGrid1.ClientID %>").get_masterTableView();
        masterTable.fireCommand("Page", "Next");
    }
</script>

Thanks,
Princy
0
David
Top achievements
Rank 1
answered on 13 Nov 2013, 12:52 PM
Thanks! I passed in the page number as "1" and it worked for me.
Tags
Grid
Asked by
David
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
David
Top achievements
Rank 1
Share this question
or