日期:2014-05-17 浏览次数:20837 次
<?php /* Copyright: Paul Hanlon Released under the MIT/BSD licence which means you can do anything you want with it, as long as you keep this copyright notice */ class jQTreeTable{ public function init($map,$options,$tbodyid){ $script = <<<EOT $(function(){//Initialise the treetable var map1=[0, 0, 2, 3, 4, 4, 6, 4, 2, 9, 10, 0, 0, 13, 0, 0, 0, 17, 17, 0], map2=[$map]; var options1 = {openImg: "../images/tv-collapsable.gif", shutImg: "../images/tv-expandable.gif", leafImg: "../images/tv-item.gif", lastOpenImg: "../images/tv-collapsable-last.gif", lastShutImg: "../images/tv-expandable-last.gif", lastLeafImg: "../images/tv-item-last.gif", vertLineImg: "../images/vertline.gif", blankImg: "../images/blank.gif", collapse: false, column: 1, striped: true, highlight: true, state:true}; $("#treet1").jqTreeTable(map1, options1); $("#treet2").jqTreeTable(map2, {$options}); }); EOT; $style = <<<EOT .collapsed { display: none; } .tablemain {background-color:#ccf;border-collapse: collapse; border: solid 1px #447; padding: 0px; text-align: left; } .tablemain td {margin-left:3px;} #treet1 {background-color:#ffc} #treet2 {background-color:#ffc} #treet1 td { font: normal 10pt Arial; padding: 0px 2px 0px 0px; cursor: pointer;} #treet2 td { font: normal 10pt Arial; padding: 0px 2px 0px 0px; cursor: pointer;} .adeimg, .ttimage, .parimg, .preimg { border: none; margin: 0px; padding: 0px; vertical-align: bottom; width: 16px; height: 16px; } .adeimg, .parimg {cursor: pointer; } .even { background-color: #ddd; } .over { background-color: #66f; } EOT; return array($script,$style); } } $demo1 = <<<EOT <table class="tablemain"><thead><tr><th>Row No</th><th>Description</th><th>Path to Row</th><th>Level</th><th>Status</th></tr></thead> <tbody id="treet1"> <tr><td>1</td><td>Child of 0</td><td>[0, 1]</td><td>1</td><td></td></tr> <tr><td>2</td><td>Child of 0</td><td>[0, 2] </td><td>1</td><td></td></tr> <tr><td>3</td><td>Child of 2</td><td>[0, 2, 3] </td><td>2</td><td></td></tr> <tr><td>4</td><td>Child of 3</td><td>[0, 2, 3, 4] </td><td>3</td><td></td></tr> <tr><td>5</td><td>Child of 4</td><td>[0, 2, 3, 4, 5] </td><td>4</td><td></td></tr> <tr><td>6</td><td>Child of 4</td><td>[0, 2, 3, 4, 6] </td><td>4</td><td></td></tr> <tr><td>7</td><td>Child of 6</td><td>[0, 2, 3, 4, 6, 7] </td><td>5</td><td></td></tr> <tr><td>8</td><td>Child of 4</td><td>[0, 2, 3, 4, 8] </td><td>4</td><td></td></tr> <tr><td>9</td><td>Child of 2</td><td>[0, 2, 9] </td><td>2</td><td></td></tr> <tr><td>10</td><td>Child of 9</td><td>[0, 2, 9, 10] </td><td>3</td><td></td></tr> <tr><td>11</td><td>Child of 10</td><td>[0, 2, 9, 10, 11] </td><td>4</td><td></td></tr> <tr><td>12</t