是否可以根据特定的Select值自动设置js-GRID文本字段?

用户名

我知道目前还不清楚,但我向您展示了这张图片:

看这里

我希望在选择数据类型时根据以下内容设置“数据库数据”文本字段:

数据类型– DB数据类型

一种。STRING-varchar(100)

b。整数–整数

C。长-Bigint

例如 :

1)当我从“数据类型”中选择“字符串”以能够将“数据库数据类型”文本字段设置为varchar(100)或

2)当我从“数据类型”中选择“整数”以便能够将“数据库数据类型”文本字段设置为int或

3)当我从“数据类型”中选择“长”以便能够将“数据库数据类型”文本字段设置为Bigint时。

我的代码如下:

$("#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 row?",
                controller: process_variables,
                fields: [
                    { name: "ID", align: "center", width: 10 },
                    { name: "Name", validate: { message: "Field Name is required", validator: function(message) { return message; } }, align: "center", type: "text", width: 100 },
                    { name: "Display Name", validate: { message: "Field Display Name is required", validator: function(message) { return message; } }, align: "center", type: "text", width: 100 },
                    { name: "Data Type", validate: { message: "Field Data Type is required", validator: function(value) { return value != ""; } }, align: "center", type: "select", items: process_variables.dataType, valueField: "Name", textField: "Name", width: 45 },
                    { name: "Initial Value", align: "center", type: "text", width: 40 },
                    { name: "Initial State", validate: { message: "Field Initial State is required", validator: function(value) { return value != ""; } }, align: "center", type: "select", items: process_variables.initialState, valueField: "Name", textField: "Name", width: 40 },
                    { name: "Worklist Order", align: "center", type: "number", width: 25 },
                    { name: "DB Datatype", validate: { message: "Field DB Datatype is required", validator: function(message) { return message; } }, align: "center", type: "text", width: 45 },
                    { name: "Allowed values", align: "center", type: "text", width: 100 },
                    { type: "control", width: 25 }
                ]

        });

这是我的js-GRID数据库:

(function() {

    var total_data_ids = 8;
    var process_variables = {

        loadData: function(filter) {
            return $.grep(this.clients, function(client) {
                return (!filter.ID || client.ID.indexOf(filter.ID) > -1)
                    && (!filter.Name || client.Name.indexOf(filter.Name) > -1)
                    && (!filter.Displayed_name || client.Displayed_name.indexOf(filter.Displayed_name) > -1)
                    && (!filter.Data_type || client.Data_type === filter.Data_type)
                    && (!filter.Initial_value || client.Initial_value.indexOf(filter.Initial_value) > -1)
                    && (!filter.Initial_state || client.Initial_state === filter.Initial_state)
                    && (!filter.Worklist_order || client.Worklist_order === filter.Worklist_order)
                    && (!filter.process_variables_datatype || client.process_variables_datatype.indexOf(filter.process_variables_datatype) > -1)
                    && (!filter.Allowed_values || client.Allowed_values.indexOf(filter.Allowed_values) > -1);
            });
        },

        insertItem: function(insertingClient) {
            insertingClient.ID = total_data_ids;
            this.clients.push(insertingClient);
            $("#DataJson").html(JSON.stringify(this.clients));
            total_data_ids++;

        },

        updateItem: function(updatingClient) {
            $("#DataJson").html(JSON.stringify(this.clients));
        },

        deleteItem: function(deletingClient) {
            var clientIndex = $.inArray(deletingClient, this.clients);
            this.clients.splice(clientIndex, 1);
            $("#DataJson").html(JSON.stringify(this.clients));
        }

    };

    process_variables.dataType = [
        { Name: "STRING", Id: 0 },
        { Name: "INTEGER", Id: 1 },
        { Name: "DOUBLE", Id: 2 },
        { Name: "DATE", Id: 3 },
        { Name: "DATETIME", Id: 4 },
        { Name: "BOOLEAN", Id: 5 },
        { Name: "COMMENT", Id: 6 },
        { Name: "FILE", Id: 7 },
        { Name: "EMAIL_ADDRESS", Id: 8 },
        { Name: "AFM", Id: 9 },
        { Name: "ENTITY", Id: 10 },
        { Name: "LONG", Id: 11 }
    ];

    process_variables.initialState = [
        { Name: "HIDE", Id: 0 },
        { Name: "READ ONLY", Id: 1 },
        { Name: "WRITE", Id: 2 },
        { Name: "WRITE REQUIRED", Id: 3 }
    ];

    process_variables.clients = [];

    window.process_variables = process_variables;

}());
用户名

这很难,但我已解决。这是最终的代码,就像一个魅力一样工作:

$("#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 row?",
                controller: process_variables,
                fields: [
                    { name: "ID", align: "center", width: 10 },
                    { name: "Name", validate: { message: "Field Name is required", validator: function(message) { return message; } }, align: "center", type: "text", width: 100 },
                    { name: "Display Name", validate: { message: "Field Display Name is required", validator: function(message) { return message; } }, align: "center", type: "text", width: 100 },
                    { name: "Data Type", insertTemplate: function() {
                    var grid = this._grid;
                    var insertResult = jsGrid.fields.select.prototype.insertTemplate.call(this, arguments);
                    var defaultInsertValue = insertResult.val();
                    //alert("i default timi einai: " + defaultInsertValue);
                    //alert(JSON.stringify(insertResult.val()));

                    insertResult.on("change", function() {
                    var selectedInsertValue = insertResult.val();
                    //alert("i selected timi einai: " + selectedInsertValue);
                    var anotherInsertFieldIndex = 7;
                    if (selectedInsertValue == "STRING") grid.option("fields")[anotherInsertFieldIndex].insertControl.val("varchar(100)");
                    else if (selectedInsertValue == "INTEGER") grid.option("fields")[anotherInsertFieldIndex].insertControl.val("int");
                    else if (selectedInsertValue == "DOUBLE") grid.option("fields")[anotherInsertFieldIndex].insertControl.val("Real");
                    else if (selectedInsertValue == "DATE") grid.option("fields")[anotherInsertFieldIndex].insertControl.val("Datetime");
                    else if (selectedInsertValue == "DATETIME") grid.option("fields")[anotherInsertFieldIndex].insertControl.val("Datetime");
                    else if (selectedInsertValue == "BOOLEAN") grid.option("fields")[anotherInsertFieldIndex].insertControl.val("varchar(5)");
                    else if (selectedInsertValue == "COMMENT") grid.option("fields")[anotherInsertFieldIndex].insertControl.val("ntext");
                    else if (selectedInsertValue == "FILE") grid.option("fields")[anotherInsertFieldIndex].insertControl.val("varchar(250)");
                    else if (selectedInsertValue == "EMAIL_ADDRESS") grid.option("fields")[anotherInsertFieldIndex].insertControl.val("varchar(100)");
                    else if (selectedInsertValue == "AFM") grid.option("fields")[anotherInsertFieldIndex].insertControl.val("varchar(100)");
                    else if (selectedInsertValue == "ENTITY") grid.option("fields")[anotherInsertFieldIndex].insertControl.val("varchar(2000)");
                    else if (selectedInsertValue == "LONG") grid.option("fields")[anotherInsertFieldIndex].insertControl.val("Bigint");
                    });
                    return insertResult;
                    }, editTemplate: function() {
                    var grid = this._grid;
                    var editResult = jsGrid.fields.select.prototype.editTemplate.call(this, arguments);

                    editResult.on("change", function() {
                    var selectedEditValue = editResult.val();
                    var anotherEditFieldIndex = 7;
                    if (selectedEditValue == "STRING") grid.option("fields")[anotherEditFieldIndex].editControl.val("varchar(100)");
                    else if (selectedEditValue == "INTEGER") grid.option("fields")[anotherEditFieldIndex].editControl.val("int");
                    else if (selectedEditValue == "DOUBLE") grid.option("fields")[anotherEditFieldIndex].editControl.val("Real");
                    else if (selectedEditValue == "DATE") grid.option("fields")[anotherEditFieldIndex].editControl.val("Datetime");
                    else if (selectedEditValue == "DATETIME") grid.option("fields")[anotherEditFieldIndex].editControl.val("Datetime");
                    else if (selectedEditValue == "BOOLEAN") grid.option("fields")[anotherEditFieldIndex].editControl.val("varchar(5)");
                    else if (selectedEditValue == "COMMENT") grid.option("fields")[anotherEditFieldIndex].editControl.val("ntext");
                    else if (selectedEditValue == "FILE") grid.option("fields")[anotherEditFieldIndex].editControl.val("varchar(250)");
                    else if (selectedEditValue == "EMAIL_ADDRESS") grid.option("fields")[anotherEditFieldIndex].editControl.val("varchar(100)");
                    else if (selectedEditValue == "AFM") grid.option("fields")[anotherEditFieldIndex].editControl.val("varchar(100)");
                    else if (selectedEditValue == "ENTITY") grid.option("fields")[anotherEditFieldIndex].editControl.val("varchar(2000)");
                    else if (selectedEditValue == "LONG") grid.option("fields")[anotherEditFieldIndex].editControl.val("Bigint");
                    });
                    return editResult;
                    }, validate: { message: "Field Data Type is required", validator: function(value) { return value != "Select"; } }, align: "center", type: "select", items: process_variables.dataType, valueField: "Name", textField: "Name", width: 45 },
                    { name: "Initial Value", align: "center", type: "text", width: 40 },
                    { name: "Initial State", validate: { message: "Field Initial State is required", validator: function(value) { return value != ""; } }, align: "center", type: "select", items: process_variables.initialState, valueField: "Name", textField: "Name", width: 40 },
                    { name: "Worklist Order", align: "center", type: "number", width: 25 },
                    { name: "DB Datatype", validate: { message: "Field DB Datatype is required", validator: function(message) { return message; } }, align: "center", type: "text", width: 45 },
                    { name: "Allowed values", align: "center", type: "text", width: 100 },
                    { type: "control", width: 25 }
                ]

        });

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

设置片段的文本字段

来自分类Dev

从文本字段检索值

来自分类Dev

如何根据 Flutter 中另一个文本字段的值自动设置文本字段的值?

来自分类Dev

根据文本字段值移动 UIslider

来自分类Dev

使用uidatepicker设置文本字段值

来自分类Dev

通过.value设置文本字段的值

来自分类Dev

使用 javascript 设置文本字段的值

来自分类Dev

根据焦点自动在文本字段上显示隐藏值

来自分类Dev

如何在文本字段中设置特定值?

来自分类Dev

是否可以创建 pdf 格式的文本字段,该字段可以根据文本绑定的大小增加?

来自分类Dev

Swift文本字段自动换行

来自分类Dev

Swift文本字段自动换行

来自分类Dev

如何自动清除文本字段

来自分类Dev

从自动完成填充文本字段

来自分类Dev

根据下拉选择填充文本字段

来自分类Dev

根据其他文本字段的输入填充文本字段初始值

来自分类Dev

根据现有文本字段中的值创建新的文本字段

来自分类Dev

根据现有文本字段中的值创建新的文本字段

来自分类Dev

如何设置这种文本字段的样式

来自分类Dev

设置文本字段的数值范围

来自分类Dev

设置文本字段onfocus的背景颜色

来自分类Dev

从文本字段设置画布大小

来自分类Dev

设置多个文本字段的最大长度

来自分类Dev

检查文本字段是否为空

来自分类Dev

在特定文本字段之间提取数据

来自分类Dev

Javascript获取多个文本字段的值

来自分类Dev

Magento文本字段属性的值集合

来自分类Dev

访问动态文本字段值android

来自分类Dev

将下拉值插入文本字段