【问题标题】:Telerik RadGrid $find returns null after jquery dialog is closedTelerik RadGrid $find 在 jquery 对话框关闭后返回 null
【发布时间】:2012-10-03 20:22:35
【问题描述】:

我有一个复选框,当单击该复选框时,会选中或取消选中 Telerik RadGrid 中存在的所有复选框。

function CheckAll(sender, args) {
        // Set all the checkboxes according to the master
        $(":checkbox").attr("checked", sender.get_checked());

        // If "check all", do some other stuff
        if(sender.get_checked())
        {
            var masterTable = $find("<%=gridSubmittedRequests.ClientID%>").get_masterTableView();
            var rows = masterTable.get_dataItems(); // row collection
            // do some other stuff                
        }
    }
}

这一切正常,直到我打开(和关闭)一个 jquery 对话框,然后

$find("<%=gridSubmittedRequests.ClientID%>")

返回空值。因此,我永远无法到达重要的// do some other stuff 部分。

jQuery 对话框关闭函数并没有做任何特别的事情:

$("#divProcessModal").dialog(
        {
            height: 300,
            width: 400,
            modal: true,
            resizable: false,
            buttons: { 
                "Process request(s)": function (e) { 
                    // process requests
                },
                "Close without processing": function (e) { 
                    $(this).dialog("close"); 
                    e.preventDefault(); 
                }
            },
            title: "Process Request(s)",
        });

我只需点击Close without processing 按钮。
我尝试过的事情包括在服务器端注册脚本,并将主表设置为全局变量,但没有成功。

更新

我知道是什么原因了。 jquery对话框的内容是另一个页面

$("#divProcessModal").load("/ProcessRequests.aspx?requestList="+requestList);

这个页面有它自己的表单、代码隐藏等等,这似乎是导致问题的原因。我想我可以将 ProcessRequests.aspx 中的所有功能移动到当前的 aspx 页面,但是如果有人能解释发生了什么以及为什么我的初始方法不起作用,我将不胜感激。

【问题讨论】:

  • 对话框内容是否在表单中间?
  • 容器
    在主窗体中,但是当我打开对话框时,我没有将它附加到窗体中。我尝试附加它(否则我不需要),但它没有改变任何东西。

标签: jquery telerik webforms telerik-grid


【解决方案1】:

我知道是什么原因了。 jquery对话框的内容是另一个页面

$("#divProcessModal").load("/ProcessRequests.aspx?requestList="+requestList); 这个页面有它自己的形式,代码隐藏等等,这似乎是导致问题的原因。将 ProcessRequests.aspx 中的所有功能移至当前的 aspx 页面即可解决问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-28
    • 1970-01-01
    相关资源
    最近更新 更多