DIR : /home/kozerus/public_html/ko_center/js/jqgrid_demo35/treegrid.html
/home/kozerus/public_html/ko_center/js/jqgrid_demo35
<div style="font-size:12px;">
This example shows the tree grid feature of jqGrid. Currently jqGrid support only a Nested Set Model.<br>
The Adjacency List Model will be supported soon. All you need is to set treeGrid option to true,<br>
and to specify which column is expandable. Of course the data from the server should be ajusted in appropriate way.<br>
</div>
<br />
<table id="treegrid" class="scroll" cellpadding="0" cellspacing="0"></table>
<div id="ptreegrid" class="scroll"></div>
<script src="treegrid.js" type="text/javascript"> </script>
<br />
<div style="font-size:12px;">
<b> HTML </b>
<XMP>
...
<table id="treegrid" class="scroll" cellpadding="0" cellspacing="0"></table>
<div id="ptreegrid" class="scroll"></div>
<script src="treegrid.js" type="text/javascript"> </script>
</XMP>
<b>Java Scrpt code</b>
<XMP>
...
jQuery("#treegrid").jqGrid({
url: 'server.php?q=tree',
treedatatype: "xml",
mtype: "POST",
colNames:["id","Account","Acc Num", "Debit", "Credit","Balance"],
colModel:[
{name:'id',index:'id', width:1,hidden:true,key:true},
{name:'name',index:'name', width:180},
{name:'num',index:'acc_num', width:80, align:"center"},
{name:'debit',index:'debit', width:80, align:"right"},
{name:'credit',index:'credit', width:80,align:"right"},
{name:'balance',index:'balance', width:80,align:"right"}
],
height:'auto',
pager : jQuery("#ptreegrid"),
imgpath: gridimgpath,
treeGrid: true,
ExpandColumn : 'name',
caption: "Treegrid example"
});
</XMP>
<b> PHP code </b>
<XMP>
$node = (integer)$_REQUEST["nodeid"];
// detect if here we post the data from allready loaded tree
// we can make here other checks
if( $node >0) {
$n_lft = (integer)$_REQUEST["n_left"];
$n_rgt = (integer)$_REQUEST["n_right"];
$n_lvl = (integer)$_REQUEST["n_level"];
$n_lvl = $n_lvl+1;
$SQL = "SELECT account_id, name, acc_num, debit, credit, balance, level, lft, rgt FROM accounts WHERE lft > ".$n_lft." AND rgt < ".$n_rgt." AND level = ".$n_lvl." ORDER BY lft";
} else {
// initial grid
$SQL = "SELECT account_id, name, acc_num, debit, credit, balance, level, lft, rgt FROM accounts WHERE level=0 ORDER BY lft";
}
$result = mysql_query( $SQL ) or die("Couldn t execute query.".mysql_error());
if ( stristr($_SERVER["HTTP_ACCEPT"],"application/xhtml+xml") ) {
header("Content-type: application/xhtml+xml;charset=utf-8"); } else {
header("Content-type: text/xml;charset=utf-8");
}
$et = ">";
echo "<?xml version='1.0' encoding='utf-8'?$et\n";
echo "<rows>";
echo "<page>1</page>";
echo "<total>1</total>";
echo "<records>1</records>";
// be sure to put text data in CDATA
while($row = mysql_fetch_array($result,MYSQL_ASSOC)) {
echo "<row>";
echo "<cell>". $row[account_id]."</cell>";
echo "<cell>". $row[name]."</cell>";
echo "<cell>". $row[acc_num]."</cell>";
echo "<cell>". $row[debit]."</cell>";
echo "<cell>". $row[credit]."</cell>";
echo "<cell>". $row[balance]."</cell>";
echo "<cell>". $row[level]."</cell>";
echo "<cell>". $row[lft]."</cell>";
echo "<cell>". $row[rgt]."</cell>";
if($row[rgt] == $row[lft]+1) $leaf = 'true';else $leaf='false';
echo "<cell>".$leaf."</cell>";
echo "<cell>false</cell>";
echo "</row>";
}
echo "</rows>";
</XMP>
</div>
//
koh5_pano
Drag mouse to navigate.
Navigation
- Left/Right Mouse drag: Changes camera heading.
- Up/Sown Mouse drag: Changes camera pitch.
- Scroll wheel: Changes camera field of view.
- I-Key: Displays Info panel with canvas size, image size and FPS.
17.Aug.2010, Martin Wengenmayer