I have gotten a bit further, but seems like need someone's help.
My code.
Markup
<div>
<table easy-grid id="dg" class="easyui-treegrid" title="Folder Browser" style="width:700px;height:250px">
</table>
</div>
Controller:
charts.directive('easyGrid',
function () {
return {
restrict: 'AEC',
transclude: true,
link: function (scope, element, attrs) {
element.datagrid({
url: 'treegrid_data2.json',
columns: [[
{ field: 'name', title: 'Name', width: 100 },
{ field: 'persons', title: 'Person', width: 100 }
]],
iconCls: 'icon-ok',
collapsible: true,
method: 'get',
//data: scope.data,
idField: 'id',
treeField: 'name'
});
}
};
});
If I use 'treegrid_data2.json' then I get columns but no data is shown. If I use scope.data as is in my other post then I do get data, but it's hierarchical. I cannot expand or collapse it.
Data:
var data = '<root><assets ID="1" name="All Assets"><assets ID="104" parentID="1" name="EXAMPLE COMPANY"/><assets ID="109" parentID="104" name="CHICAGO"/></assets></root>';
var xml = $.parseXML(data);
var rows = [];
$(xml).find('assets').each(function () {
rows.push({
id: $(this).attr('ID'),
name: $(this).attr('name'),
_parentId: $(this).attr('parentID')
});
});
$scope.data = { total: rows.length, rows: rows };
Result is attached.
Please help, I really need that.