课程表

jEasyUI 应用

jEasyUI 拖放

jEasyUI 菜单与按钮

jEasyUI 布局

jEasyUI 数据网格

jEasyUI 窗口

jEasyUI 树形菜单

jEasyUI 表单

jEasyUI 参考手册

工具箱
速查手册

jEasyUI 树形网格动态加载

当前位置:免费教程 » JS/JS库/框架 » jQuery EasyUI

动态加载树形网格有助于从服务器上加载部分的行数据,避免加载大型数据的长时间等待。本教程将向您展示如何创建带有动态加载特性的树形网格(TreeGrid)。

创建树形网格(TreeGrid)

  1. <table title="Products" class="easyui-treegrid" style="width:700px;height:300px"
  2. url="treegrid3_getdata.php"
  3. rownumbers="true"
  4. idField="id" treeField="name">
  5. <thead>
  6. <tr>
  7. <th field="name" width="250">Name</th>
  8. <th field="quantity" width="100" align="right">Quantity</th>
  9. <th field="price" width="150" align="right" formatter="formatDollar">Price</th>
  10. <th field="total" width="150" align="right" formatter="formatDollar">Total</th>
  11. </tr>
  12. </thead>
  13. </table>

服务器端代码

treegrid3_getdata.php

  1. $id = isset($_POST['id']) ? intval($_POST['id']) : 0;
  2.  
  3. include 'conn.php';
  4. $result = array();
  5. $rs = mysql_query("select * from products where parentId=$id");
  6. while($row = mysql_fetch_array($rs)){
  7. $row['state'] = has_child($row['id']) ? 'closed' : 'open';
  8. $row['total'] = $row['price']*$row['quantity'];
  9. array_push($result, $row);
  10. }
  11.  
  12. echo json_encode($result);
  13.  
  14. function has_child($id){
  15. $rs = mysql_query("select count(*) from products where parentId=$id");
  16. $row = mysql_fetch_array($rs);
  17. return $row[0] > 0 ? true : false;
  18. }

下载 jQuery EasyUI 实例

jeasyui-tree-treegrid3.zip

转载本站内容时,请务必注明来自W3xue,违者必究。
 友情链接:直通硅谷  点职佳  北美留学生论坛

本站QQ群:前端 618073944 | Java 606181507 | Python 626812652 | C/C++ 612253063 | 微信 634508462 | 苹果 692586424 | C#/.net 182808419 | PHP 305140648 | 运维 608723728

W3xue 的所有内容仅供测试,对任何法律问题及风险不承担任何责任。通过使用本站内容随之而来的风险与本站无关。
关于我们  |  意见建议  |  捐助我们  |  报错有奖  |  广告合作、友情链接(目前9元/月)请联系QQ:27243702 沸活量
皖ICP备17017327号-2 皖公网安备34020702000426号