I worked out how to correctly format the json data source in hierarchical format using php.
This means you don't have to use the loadFilter method.
Example of a correctly formatted JSON output (not based on my php select query - just in terms of structure):
[{
"id":1,
"text":"Folder1",
"iconCls":"icon-save",
"children":[{
"text":"File1",
"checked":true
},{
"text":"Books",
"state":"open",
"attributes":{
"url":"/demo/book/abc",
"price":100
},
"children":[{
"text":"PhotoShop",
"checked":true
},{
"id": 8,
"text":"Sub Bookds",
"state":"closed"
}]
}]
},{
"text":"Languages",
"state":"closed",
"children":[{
"text":"Java"
},{
"text":"C#"
}]
}]
Here is the data_select.php file.
Note:
id field is account_id
parent id field is parent_id
<?php
include '../../common/conn.php';
$refs = array();
$list = array();
$sql = "SELECT
account.account_id,
account.AccountName,
account.parent_id,
account.AccountType,
account.AccountNumber
FROM
account";
$result = mysql_query($sql);
while($data = @mysql_fetch_assoc($result)) {
$thisref = &$refs[ $data['account_id'] ];
$thisref['account_id'] = $data['account_id'];
$thisref['AccountName'] = $data['AccountName'];
$thisref['parent_id'] = $data['parent_id'];
$thisref['AccountType'] = $data['AccountType'];
$thisref['AccountNumber'] = $data['AccountNumber'];
if ($data['parent_id'] == 0) {
$list[ ] = &$thisref;
} else {
$refs[ $data['parent_id'] ]['children'][] = &$thisref;
}
}
$mylist["rows"] = $list;
echo json_encode($mylist);
?>
The above will extract ALL records.
Note: parent_id should be '0' by default not NULL.
Does anyone know how to use this method to combine it with support for pagination? Ideally I would like to expand all nodes by default but offer pagination...