浅谈EasyUI中编辑treegrid的方法

2022-01-14,,,,

本文给大家介绍的是在EasyUI中编辑treegid的方法,并附上具体的实例,这里推荐给大家,有需要的小伙伴快来参考下吧。

主从表,从表是一个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的方法,希望大家能够喜欢。

以上就是浅谈EasyUI中编辑treegrid的方法的详细内容,更多请关注本站其它相关文章!

《浅谈EasyUI中编辑treegrid的方法.doc》

下载本文的Word格式文档,以方便收藏与打印。