ASP updatePanels未定义可滚动网格插件offsetWidth

Scrollable grid plugin offsetWidth undefined with ASP updatePanels

本文关键字:网格 插件 offsetWidth 滚动 updatePanels 未定义 ASP      更新时间:2023-09-26

我正在尝试使我的网格视图可滚动,我的网格包含在更新面板中,我正在pageLoad()中调用以下函数

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

在另一个updatePanel的一些updatePanel部分回发后,jQuery scrollableGridPlugin给出了一个未定义的offsetWidth错误,我试图通过先发制人地检查来解决这个问题

if(grid.rows.length>0)

但这并没有抓住它,即使offsetWidth未定义的行显示grid.rows.length的值为零。这让我相信,在调用.screllable()的过程中,不知何故有什么东西在修改网格

抱歉,我无法从jQuery中找到原始插件链接,但这里是它使用的例子

插件示例

我发现,由于我的jQuery选择器使用了CSS类名标识符,通过创建另一个具有相同类的网格视图(几乎就像修改全局命名空间中对象的递归错误),插件变得很混乱

通过gridview ID将jQuery选择器更改为已修复问题

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

可滚动插件包括以下几行,用于将属性从原始gridview复制到新的标头gridview,请注意,它没有复制id,因此,由id调用.coscrollable()似乎是非官方支持的使用该插件的方式。

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);
  }
}