Ticket Q200879
Visible to All Users

Client Side PageChanged Event

created 16 years ago

I need the desired functionality to be implemented.
On a aspxgridview the user changes page clicking on one of the page controls at the bottom of the page.
When this happens I need to be able to scroll the page to the top of it. Scrolling is not an issue.
I've tried to find a client side event for the aspxgridview that fires when a page is changed however I couldn't find one.
Also I've handled PageIndexChanged server side event and passing a custom JSProperty so I can identify on the client side if the page has changed like this:
Server Code:
 public bool pageChanged;
        protected void gvPremiums_PageIndexChanged(object sender, EventArgs e)
        {
            pageChanged = true;
        }
        protected void gvPremiums_BeforeGetCallbackResult(object sender, EventArgs e)
        {
            gvPremiums.JSProperties["cp_PageChanged"] = "1";
            if (!gvPremiums.JSProperties.ContainsKey("cp_PageChanged") )
            {
                gvPremiums.JSProperties["cp_PageChanged"] = string.Empty;
            }
        }
Client Side Code:
if(e.cp_PageChanged != '')
{
          scrollTop();
}
Can you suggest something?

Comments (1)
DevExpress Support Team 16 years ago

    Hello Mihai,
    Your idea about handling the server-side PageIndexChanged event and passing a custom JSProperty to the client seems to be correct. The only change I've done is reseting a custom JSProperty in the Page_Load event handler. So, if you perform the PageIndexChanged event, the custom JSProperty will be set to 1. Otherwise, it will be set to 0. See my code sample below:

    C#
    protected void Page_Load(object sender, EventArgs e) { ASPxGridView1.JSProperties["cpPageChanged"] = 0; } protected void ASPxGridView1_PageIndexChanged(object sender, EventArgs e) { (sender as ASPxGridView).JSProperties["cpPageChanged"] = 1; }
    ASPx
    <ClientSideEvents EndCallback="function(s, e) { if(grid.cpPageChanged == 1) window.alert('Page changed!'); }" />

    The cpPageChanged value is checked on the client side, in the grid's EndCallback event handler.
    Attached is complete sample code.
    Regards,
    Alistair.

    Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

    Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.