Tuesday, May 27, 2014

manipulating HTML whenever pagination changes within a DevExpress ASPxGridView

Here is my challenge. I put an ASPxGridView inside an existing page. I wanted it to be wider than the div it would sit within would allow so I gave it absolute positioning and made it sit within the div it had to sit within within a middleman div which had a fixed height creating the illusion that the ASPxGridView was pushing the rest of the content below on the page downwards. This illusion was shattered when I pressed the "All" button or when the last page in the pagination (with fewer records than the other pages) was visited. I needed a way to alter the height of the middleman div when the pagination changed. This touches on how to do so a little bit. In my implementation I am adding this tag inside my ASPxGridView:

<ClientSideEvents EndCallback="AdjustHeightOfDivHoldingPaymentConfigurations" />

 
 

On the C# side I then have an event like so:

private void Foo_PageIndexChanged(object sender, EventArgs e)
{
   Foo.JSProperties["cp_PageChanged"] = "whatever";
}

 
 

And in JavaScript I'll do something like this:

function AdjustHeightOfDivHoldingPaymentConfigurations(s, e) {
   alert(s.cp_PageChanged);
}

 
 

The alert will surface the "whatever" and by this process with cp_ variables one may hand the number of records shown to JavaScript where the height of the middleman div may be restyled appropriately.

No comments:

Post a Comment