Question

I am trying to make my gridviews scrollable, my gridviews are contained in update panels and I'm calling the following function in pageLoad()

function LoadScrollPopupOverridesBehavior() {
    $('.GridViewPopupWithOverride').Scrollable({
        ScrollHeight: 350,
        Width: 733
    });
    $('.GridViewPopupWithoutOverride').Scrollable({
        ScrollHeight: 350,
        Width: 733
    });
}

After some updatePanel partial postbacks from another updatePanel the jQuery scrollableGridPlugin is giving an error offsetWidth undefined, I attempted to resolve this by preemptively checking for

if(grid.rows.length>0)

But this didn't catch it even though the line for offsetWidth undefined showed that the value for grid.rows.length was zero. This is leading me to believe that somehow something is modifying the grids during the call to .scrollable()

Sorry, I'm unable to find the original plugin link from jQuery, but here is the example of it's use

Plugin Example

Was it helpful?

Solution

I discovered that because my jQuery selector was using a CSS class name identifier, the plugin was getting confused, by creating another gridview with the same class (almost like a recursion error by modifying objects in the global namespace)

changing the jQuery selector to be by gridview ID's fixed the issue

function LoadScrollPopupOverridesBehavior() {
$('#MainContent_GridViewPopupWithOverride').Scrollable({
    ScrollHeight: 350,
    Width: 733
});

$('#MainContent_GridViewPopupWithoutOverride').Scrollable({
    ScrollHeight: 350,
    Width: 733
});
}

The scrollable plugin includes the following lines to copy the attributes from the original gridview to the new header gridview, notice it does not copy the id thus, calling the .scrollable() by id seems to be the unofficial supported way of using the plugin.

for (i = 0; i < grid.attributes.length; i++) {
  if (grid.attributes[i].specified && grid.attributes[i].name != "id") {
    table.setAttribute(grid.attributes[i].name, grid.attributes[i].value);
  }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top