JavaScript
var gridData = [
{fid: '13',filename:'index.html'},
{fid: '14',filename:'about.html'}
];
var treeData = [{
"id":1,
"text":"My Documents",
"children":[{
"id":11,
"text":"Photos",
"state":"closed",
"children":[{
"id":111,
"text":"Friend"
},{
"id":112,
"text":"Wife"
},{
"id":113,
"text":"Company"
}]
},{
"id":12,
"text":"Program Files",
"children":[{
"id":121,
"text":"Intel"
},{
"id":122,
"text":"Java",
"attributes":{
"p1":"Custom Attribute1",
"p2":"Custom Attribute2"
}
},{
"id":123,
"text":"Microsoft Office"
},{
"id":124,
"text":"Games",
"checked":true
}]
},{
"id":13,
"text":"index.html"
},{
"id":14,
"text":"about.html"
},{
"id":15,
"text":"welcome.html"
}]
}]
$(function(){
var dg = $('#dg');
dg.edatagrid({
title:"edatagrid with combotree editor",
fit:true, singleSelect:true, striped:true, rownumbers: true, fitColumns: true,
data:gridData,
columns:[[
{field:'fid', title:'FileName', width:200,
formatter:function(value,row){
return row.filename || value;
},
editor:{
type:'combotree',
options:{
panelHeight: 160,
url: '/echo/json/',
onBeforeLoad: function(node,param) {
param.delay = 0.2; //simulate a small delay
//add result data for jsfidle echo jason
param.json = JSON.stringify(treeData);
},
}
}
},
{field:'comments',title:'Comment',width:240,editor:'text'}
]],
onBeginEdit: function(index,row){
var ed = $(this).datagrid('getEditor', {index:index,field:'fid'});
$(ed.target).combotree('setValue', row.fid);
$(ed.target).combotree('setText', row.filename);
},
onEndEdit: function(index,row){
...