$tree = new jqTreeGrid($conn); $tree->SelectCommand = "SELECT * FROM nested_category"; // set the table and primary key $tree->table = 'nested_category'; $tree->setPrimaryKeyId('category_id'); // set tree model and table configuration $tree->setTreeModel('nested'); $tree->setTableConfig(array('id' => 'category_id', 'left' => 'lft', 'right' => 'rgt')); // autoloading is disabled $tree->autoLoadNodes = false; // collapse all nodes (default) $tree->expandAll = true; // show any error (if any ) from server $tree->showError = true; $tree->setColModel(); $tree->setUrl('treegrid.php'); $tree->dataType = 'json'; // Some nice setting $tree->setColProperty('name', array("label" => "Name", "width" => 170)); $tree->setColProperty('price', array("label" => "Price", "width" => 90, "align" => "right")); $tree->setColProperty('qty_onhand', array("label" => "Qty", "width" => 90, "align" => "right")); $tree->setColProperty('color', array("label" => "Color", "width" => 100)); // hide the not needed fields $tree->setColProperty('category_id', array("hidden" => true, "index" => "accounts.account_id", "width" => 50)); $tree->setColProperty('lft', array("hidden" => true)); $tree->setColProperty('rgt', array("hidden" => true)); $tree->setColProperty('level', array("hidden" => true)); $tree->setColProperty('uiicon', array("hidden" => true)); // and finaly set the expand column and height to auto $tree->setGridOptions(array("ExpandColumn" => "name", "height" => 200, "sortname" => "account_id")); $tree->renderTree('#tree', '#pager', true, null, null, true, true);
// Create the jqTreeGrid instance $tree = new jqTreeGrid($conn); $tree->SelectCommand = "SELECT * FROM adj_table"; // set the table and primary key $tree->table = 'adj_table'; $tree->setPrimaryKeyId('emp_id'); // set tree model and table configuration $tree->setTreeModel('adjacency'); $tree->setTableConfig(array('id' => 'emp_id', 'parent' => 'boss_id')); // autoloading is disabled $tree->autoLoadNodes = false; // collapse all nodes (default) $tree->expandAll = true; // show any error (if any ) from server $tree->showError = true; $tree->setColModel(); $tree->setUrl('treegrid.php'); $tree->dataType = 'json'; // Some nice setting $tree->setColProperty('name', array("label" => "Employee", "width" => 170)); $tree->setColProperty('salary', array("label" => "Salary", "align" => "right", "width" => 90)); // hide the not needed fields $tree->setColProperty('emp_id', array("hidden" => true)); $tree->setColProperty('boss_id', array("hidden" => true)); // and finaly set the expand column and height to auto $tree->setGridOptions(array("ExpandColumn" => "name", "height" => 'auto', "sortname" => "emp_id", "scrollrows" => true)); // enable key navigation $tree->callGridMethod('#tree', 'bindKeys'); $tree->navigator = true; $tree->setNavOptions('navigator', array("add" => true, "edit" => true, "del" => true, "search" => false, "excel" => false)); $tree->renderTree('#tree', '#pager', true, null, null, true, true);
// set the table and primary key $tree->table = 'accounts'; $tree->setPrimaryKeyId('account_id'); // set tree model and table configuration $tree->setTreeModel('adjacency'); $tree->setTableConfig(array('id' => 'account_id', 'parent' => 'parent_id')); // autoloading is disabled $tree->autoLoadNodes = false; // collapse all nodes (default) $tree->expandAll = true; // show any error (if any ) from server $tree->showError = true; $tree->setColModel(); $tree->setUrl('treegrid.php'); $tree->dataType = 'json'; // Some nice setting $tree->setColProperty('name', array("label" => "Name", "width" => 170)); $tree->setColProperty('acc_num', array("label" => "Number", "width" => 170)); $tree->setColProperty('debit', array("label" => "Debit", "width" => 90, "align" => "right")); $tree->setColProperty('credit', array("label" => "Credit", "width" => 90, "align" => "right")); $tree->setColProperty('balance', array("label" => "Balance", "width" => 90, "align" => "right")); // hide the not needed fields $tree->setColProperty('account_id', array("hidden" => true)); $tree->setColProperty('parent_id', array("hidden" => true)); // and finaly set the expand column and height to auto $tree->setGridOptions(array("ExpandColumn" => "name", "height" => 'auto', "sortname" => "account_id", "scrollrows" => true)); // enable key navigation $tree->callGridMethod('#tree', 'bindKeys'); $tree->navigator = true; $tree->setNavOptions('navigator', array("add" => true, "edit" => false, "del" => false, "search" => false, "excel" => false)); $tree->renderTree('#tree', '#pager', true, null, null, true, true);