当前位置:主页 > 网页前端 > jquery >

浅谈EasyUI中编辑treegrid的方法

时间:2021-10-24 10:33:57 | 栏目:jquery | 点击:

主从表,从表是一个treegrid,加载完数据后,点击节点进入编辑状态。

复制代码 代码如下:

columns : [ [ {
            title : "ID",
            field : "id",
            hidden : true
        }, {
            field : "pid",
            hidden : true
        },  {
            title : "AAA",
            field : "aaa",
            width : 70,
            align : "center",
            halign : "center"
        }, {
            title : "BBB",
            field : "bbb",
            width : 70,
            align : "center",
            halign : "center",
            editor : {
                type : "combobox",
                options : {
                    data : [ {
                        "id" : 0,
                        "text" : "苹果"
                    }, {
                        "id" : 1,
                        "text" : "梨子"
                    } ],
                    valueField : 'id',
                    textField : 'text',
                    editable : false,
                    // required : true,
                    panelHeight : "auto",
                    missingMessage : "请选择水果",
                    onSelect : function(record) {
                        //editingId是进入编辑状态行的id
                        var editors = $('#grid').datagrid('getEditors', $('#editingId').val());
                        if(record.id == 1){//选择梨子
                            var feditor = editors[1];//一行中第二个编辑框
                            //将编辑框设置成必填
                            $(feditor.target).validatebox({required:true});
                            //将编辑框设置成可编辑
                            $(feditor.target).numberbox('enable');
                            var feditor2 = editors[2];//一行中第三个编辑框
                            $(feditor2.target).validatebox({required:true});
                        }else if(record.id == 0){//选择苹果
                            var feditor = editors[1];
                            $(feditor.target).validatebox({required:false});
                            $(feditor.target).validatebox("setValue","");
                            $(feditor.target).numberbox('disable');
                            var feditor2 = editors[2];
                            $(feditor2.target).validatebox({required:false});
                            $(feditor2.target).validatebox("setValue","");
                        }
                    },
                }
            }
        }

开启编辑状态

复制代码 代码如下:

$('#rulesgrid').treegrid('beginEdit', index);

以上就是本文关于EasyUI中编辑treegrid的方法,希望大家能够喜欢。

您可能感兴趣的文章:

相关文章