I want to create tree? but it's empty...
//x:\home\localhost\www\assets\components\tests\js\mgr\widgets\home.panel.js
Tests.panel.Home = function(config) {
config = config || {};
Ext.apply(config,{
border: false
,baseCls: 'modx-formpanel'
,items: [
{ //tittle
html: '<h2>'+_('tests.management')+'</h2>'
,border: false
,cls: 'modx-page-header'
},
{ //wrapper
xtype: 'panel'
,layout: 'hbox'
,items:
[
{ //tree
xtype: 'treepanel',
region: 'west',
width: 200,
autoScroll: true,
split: true,
bodyBorder :false,
hideCollapseTool:true,
rootVisible: true, /* */
loader: aa=new Ext.tree.TreeLoader({
dataUrl: '../core/components/tests/processors/mgr/test/get_tree.php'
}),
listeners: {
click: function(n) {
Ext.Msg.alert('Navigation Tree Click', 'You clicked: "' + n.attributes.text + '"');
}
},
root: new Ext.tree.AsyncTreeNode({
expanded: true,
text: _('tests'),
draggable: false,
id: 'source'
}),
},
//modxTabs
{
xtype: 'modx-tabs',
bodyStyle: 'padding: 10px',
defaults: { border: false ,autoHeight: true },
border: true,
items: [{
title: _('tests'),
defaults: { autoHeight: true },
items: [{
html: '<p>'+_('tests.management_desc')+'</p>
',
border: false
},
{
xtype: 'tests-grid-tests',
preventRender: true
}]
}]
}//modxTabs */
]
} //wrap
]
}
);
Tests.panel.Home.superclass.constructor.call(this,config);
};
Ext.extend(Tests.panel.Home,MODx.Panel);
Ext.reg('tests-panel-home',Tests.panel.Home);
tree works
<?
//x:\home\localhost\www\core\components\tests\processors\mgr\test\get_tree.php
$sampleArr = array( array( id=>1, 'text'=>"Node 1", leaf=>true), array( id=>2, 'text'=>"Node 2", leaf=>true ) );
echo json_encode($sampleArr);
return '';
tree empty
$$isLimit = !empty($scriptProperties['limit']);
$start = $modx->getOption('start',$scriptProperties,0);
$limit = $modx->getOption('limit',$scriptProperties,20);
$sort = $modx->getOption('sort',$scriptProperties,'name');
$dir = $modx->getOption('dir',$scriptProperties,'ASC');
$query = $modx->getOption('query',$scriptProperties,'');
/* build query */
$c = $modx->newQuery('Test');
if (!empty($query)) {
$c->where(array(
'name:LIKE' => '%'.$query.'%',
'OR:description:LIKE' => '%'.$query.'%',
));
}
$count = $modx->getCount('Test',$c);
$c->sortby($sort,$dir);
if ($isLimit) $c->limit($limit,$start);
$tests = $modx->getIterator('Test', $c);
/* iterate */
$list = array();
foreach ($tests as $test) {
$testArray = $test->toArray();
$list[]=array(id=> $testArray['id'], text=> $testArray['name'], leaf=> true,);
}
return $this->outputArray($list,$count);