Jsgrid字段“必填”;内部对话不起作用

jsgrid field "required" inside dialog doesn't work

本文关键字:内部 对话 不起作用 字段 必填 Jsgrid      更新时间:2023-09-26

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

当插入validate: "required"在我下面的代码为jsgrid字段:Name jsgrid不采取所需的限制和插入块!!我几乎可以肯定,由于validate是一个参数,可以在dialog和jsgrid中定义,因此我将网格包含在对话框中会产生问题。

这是dialog的代码,其中我成功地在一个对话框中显示我的网格,但我不能通过validate:"required"。我还上传了一个screenshotGrid在对话框:

$( "#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 }
                ]
        });

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

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