DIV CSS 佈局教程網

 DIV+CSS佈局教程網 >> 網頁腳本 >> JavaScript入門知識 >> 關於JavaScript >> 淺談EasyUI中編輯treegrid的方法教程
淺談EasyUI中編輯treegrid的方法教程
編輯:關於JavaScript     

主從表,從表是一個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的方法,希望大家能夠喜歡。

XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved