对话框内的“必需”jsgrid字段不起作用

时间:2016-09-06 08:01:31

标签: javascript validation dialog field jsgrid

我想将name: "Name"字段设置为required,并根据jsgrid文档(http://js-grid.com/docs/#grid-fields)插入:validate: "required",但它不起作用。

在jsgrid字段的以下代码中插入validate: "required"时:Name jsgrid没有采取所需的限制并插入块! 我几乎可以肯定,我将网格封装在对话框中会产生问题,因为validate是一个可以在dialog和jsgrid中定义的参数。

这是带对话框的代码,我在对话框中成功显示了我的网格,但我无法通过验证:“required”。我还上传了截屏Grid inside dialog

$( "#DataGrid" ).dialog({minWidth: 1000, minHeight: 500});
            $("#DataGrid").jsGrid({
                    height: "100%",
                    width: "70%",
                    filtering: true,
                    editing: true,
                    inserting: true,
                    sorting: true,
                    paging: true,
                    autoload: true,
                    pageSize: 15,
                    pageButtonCount: 5,
                    datatype: "json",
                    deleteConfirm: "Do you really want to delete the client?",
                    controller: db,
                    fields: [
                        { name: "Id", align: "center", width: 45 },
                        { name: "Name", validate:"required," align: "center", type: "text", width: 45 },
                        { name: "Displayed Name(locale)", align: "center", type: "text", width: 40 },
                        { name: "Data Type", align: "center", type: "select", items: db.dataType, valueField: "Id", textField: "Name", width: 40 },
                        { name: "Initial Value", align: "center", type: "text", width: 40 },
                        { name: "Initial State", align: "center", type: "select", items: db.initialState, valueField: "Id", textField: "Name", width: 50 },
                        { name: "Worklist Order", align: "center", type: "number", width: 20 },
                        { name: "DB Datatype", align: "center", type: "text", width: 25 },
                        { name: "Allowed Values JSON", align: "center", type: "text", width: 20 },
                        { name: "Allowed Values SQL", align: "center", type: "text", width: 20 },
                        { type: "control", width: 25 }
                    ]

            });

我在没有对话框的情况下尝试了jsgrid代码并且它可以工作,但它在对话框中如何工作? 没有对话框的代码有效:

 $("#DataGrid").jsGrid({
                height: "100%",
                width: "70%",
                filtering: true,
                editing: true,
                inserting: true,
                sorting: true,
                paging: true,
                autoload: true,
                pageSize: 15,
                pageButtonCount: 5,
                datatype: "json",
                deleteConfirm: "Do you really want to delete the client?",
                controller: db,
                fields: [
                    { name: "Id", align: "center", width: 45 },
                    { name: "Name", validate:"required", align: "center", type: "text", width: 45 },
                    { name: "Displayed Name(locale)", align: "center", type: "text", width: 40 },
                    { name: "Data Type", align: "center", type: "select", items: db.dataType, valueField: "Id", textField: "Name", width: 40 },
                    { name: "Initial Value", align: "center", type: "text", width: 40 },
                    { name: "Initial State", align: "center", type: "select", items: db.initialState, valueField: "Id", textField: "Name", width: 50 },
                    { name: "Worklist Order", align: "center", type: "number", width: 20 },
                    { name: "DB Datatype", align: "center", type: "text", width: 25 },
                    { name: "Allowed Values JSON", align: "center", type: "text", width: 20 },
                    { name: "Allowed Values SQL", align: "center", type: "text", width: 20 },
                    { type: "control", width: 25 }
                ]

        });

有什么想法吗?这是一个复杂的问题。

1 个答案:

答案 0 :(得分:0)

好的,谢谢@ tabalin的帮助,我解决了这个问题。我少了一个jsgrid档案。现在它就像一个魅力!