日期:2014-05-17  浏览次数:20709 次

请问在easyui的grid中如何获得combotree的树对象?

我是想在点击combotree的某个树节点时给后面的隐藏域赋值,值包括选择的节点值以及它的父节点的值

function test(record){
    var rowIdx = $('#tt').datagrid('getRowIndex',$('#tt').datagrid('getSelected'));
    //给隐藏域赋选中的节点的值    
    $('#tt').datagrid('getEditor',{'index':rowIdx,'field':'hiddenObj'}).target.val(record.id+"~"+record.text);
    //如何给隐藏域赋选中节点的父节点的值??
    //要不是在grid中我可以直接通过$('#treeObj').combotree('tree').tree('getParent',record.target)
    //但是这里无法通过这个写法获得树对象!
}

function init(node, data){
    if(data[0]){
        //alert(node+", "+$.toJSON(data));
        //alert(data[0].id+","+data[0].text);
    }
}

$(function(){
    $('#tt').datagrid({
        onBeforeLoad:function(){
            $(this).datagrid('rejectChanges');
        },
        onClickRow:function(rowIndex){
            if (lastIndex != rowIndex){
                //$('#tt').datagrid('endEdit', lastIndex);
                //$('#tt').datagrid('beginEdit', rowIndex);
            }
            //lastIndex = rowIndex;
        },
        onDblClickRow:function(rowIndex){
            if (lastIndex != rowIndex){
                //$('#tt').datagrid('endEdit', lastIndex);
                $('#tt').datagrid('beginEdit', rowIndex);
            }
            lastIndex = rowIndex;
        },
        onAfterEdit:function(rowIndex){
            //alert("onAfterEdit=="+rowIndex);
        },
        onCancelEdit:function(rowIndex){
            //alert("onCancelEdit=="+rowIndex);
        }
    });
});


<table id="tt" style="width:850px;height:auto" title="Editable DataGrid" iconCls="icon-edit" singleSelect="true" idField="itemid" url="datagrid_data2.json">
    <thead>
        <tr>
            <th field="itemid" width="80">Item ID</th>
        &