KendoUI自定义命令弹出:ReferenceError:未定义wnd

时间:2013-03-25 07:48:02

标签: javascript kendo-ui kendo-grid

我正在尝试使用自定义命令弹出窗口;

 $(document).ready(function(){
        var wnd, detailsTemplate;
        $("#grid").kendoGrid({
            dataSource:{
                serverPaging: true,
                transport: {
                    read: "<?php echo base_url() ?>index.php/user_management/manage_users/list_view/"
                },
                schema:{
                    data: "data",
                    total: "total"
                },
                pageSize:5
            },
            scrollable: true,
            selectable: true,
            sortable: true,
            filterable: true,
            pageable: {
                input: true,
                numeric: false
            },

            columns: [
                {
                    field: "UserID",
                    hidden:true
                },
                {
                    field: "Username",
                    title:"Username"
                },
                { field: "FirstName",
                    title:"First Name"
                },
                {field:"MiddleNames"},
                {field:"LastName"},
                {field:"City"},
                {field:"Email"},
                //{field:"Actions"},
                {command: { text: "Details", click: showDetailsPopup }, title: " ", width: "140px" }
            ]


        });
        wnd = $("#details")
                .kendoWindow({
                    title: "Customer Details",
                    modal: true,
                    visible: false,
                    resizable: false,
                    width: 300
                }).data("data");
        detailsTemplate = kendo.template($("#template").html());


    });

    function showDetailsPopup(e) {
        e.preventDefault();
        var dataItem = this.dataItem($(e.currentTarget).closest("tr"));
        wnd.content(detailsTemplate(dataItem));
        wnd.center().open();
    }

但是当我点击网格中的“详细信息”按钮时,我在firebug中看到了这个错误;

ReferenceError: wnd is not defined
[Break On This Error]   

wnd.center().open();

更新:这是我的模板

<script type="text/x-kendo-template" id="template">
        <div id="details-container">
            <h2>#= FirstName #</h2>
        </div>
</script>

1 个答案:

答案 0 :(得分:3)

请对.data(“数据”)进行更正:

wnd = $("#details")
            .kendoWindow({
                title: "Customer Details",
                modal: true,
                visible: false,
                resizable: false,
                width: 300
           ** }).data("data");**
    detailsTemplate = kendo.template($("#template").html());


});

它应该是.data(“kendoWindow”),如下所示;

wnd = $("#details")
            .kendoWindow({
                title: "Customer Details",
                modal: true,
                visible: false,
                resizable: false,
                width: 300
           }).data("kendoWindow");
    detailsTemplate = kendo.template($("#template").html());
});