JQuery MiniUI development tutorial TreeGrid lazy loading (2)

Source: Internet
Author: User

Reference example: TreeGrid: lazy load creation Code <div id = "treegrid1" class = "mini-treegrid" style = "width: 600px; height: 250px;" url = ".. /data/TreeService. aspx? Method = LoadNodes "showTreeIcon =" true "textField =" text "idField =" id "treeColumn =" filename "onbeforeload =" onBeforeTreeLoad "> <div property =" columns "> <div name = "filename" field = "name" width = "150"> name </div> <div field = "type" width = "100"> type </div> <div field = "size" width = "100" dateFormat = "yyyy-MM-dd"> size </div> <div field = "createdate" width = "100" dateFormat = "yyyy-MM-dd"> creation date </div> the server returns data [{I D: "form", text: "Form ",...... isLeaf: false, // whether the leaf node is + and-expanded: false // The node is in the shrinking State}, ......] isLeft indicates whether the node has a lower-level node. Expanded indicates that the node is in the collapsed State. When a user clicks the "+" icon, the next-level node is automatically loaded. The current node id is passed to the background. You can also block loading events and add additional attributes: function onBeforeTreeLoad (e) {var tree = e. sender; // tree control var node = e. node; // var params = e. params; // parameter object // you can pass custom attributes params. myField = "123"; // Background: The request object obtains "myField"}. After the server processes the request and obtains the "id" attribute, it loads the array of the next-level nodes of the node, and return in JSON format. String id = Request ["id"]; if (String. isNullOrEmpty (id) id = "-1"; // obtain the String SQL = "select * from plus_file where pid = '" + id + "'order by updatedate "; arrayList folders = DBUtil. select (SQL); // determines whether a node exists. If yes, isLeaf and expanded are processed. For (int I = 0, l = folders. count; I <l; I ++) {Hashtable node = (Hashtable) folders [I]; String nodeId = node ["id"]. toString (); String sql2 = "select * from plus_file where pid = '" + nodeId + "'order by updatedate"; ArrayList nodes = DBUtil. select (sql2); if (nodes. count> 0) {node ["isLeaf"] = false; node ["expanded"] = false ;}// return JSONString json = PluSoft. utils. JSON. encode (folders); Response. write (json );

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.