EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: iskandarkbr on March 06, 2015, 08:19:59 AM



Title: combotree in datagrid
Post by: iskandarkbr on March 06, 2015, 08:19:59 AM
i've tried to add combotree as editor in datagrid. it works properly while we choose node in combotree.
the problem appear when i enter the cell to edit the data. the text on datagrid doesnt appear ini combotree's texbox.


{field:'productid',title:'Product',width:300,
                  formatter:function(value){
                     for(var i=0; i<datajson.length; i++){
                        if (datajson.id == value) return datajson.text;
                     }
                     return value;
                  },
                  editor:{
                     type:'combotree',
                     options:{
                        valueField:'id',
                        textField:'text',
                        method:'post',
                        url:'data/datajson.php',
                        loadFilter: function(rows){
                                    return convert(rows,'tree-temuan');
                                 },
                        required:true,
                        panelWidth:650
                     }
                  }
               },


Title: Re: combotree in datagrid
Post by: stworthy on March 06, 2015, 08:58:25 AM
Please update the easyui to version 1.4.2. If you are using version 1.4.1, please refer to the code below to solve your issue.
Code:
$('#dg').datagrid({
    onBeginEdit: function(index,row){
        var ed = $(this).datagrid('getEditor',{index:index,field:'productid'});
        $(ed.target).combotree({
            url: '...',
            value: row.productid
        });
    },
    onEndEdit: function(index,row){
        var ed = $(this).datagrid('getEditor',{index:index,field:'productid'});
        row.productname = $(ed.target).combotree('getText');
    }
})


Title: Re: combotree in datagrid
Post by: iskandarkbr on March 06, 2015, 06:31:14 PM
great........(Y)...thanks alot stworthy , it works

what i did is i replace url option by data: datajson variable.

acctually i've tried this before:

var ed = $(this).datagrid('getEditor', {index:index, field:'productid'});
$(ed.target).combotree('setText','tes');
var t=$(ed.target).combotree("tree");
var node=t.tree('find','2');
t.tree('select',node.target);

but it always return null for the node