Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 194665
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T16:36:53+00:00 2026-05-11T16:36:53+00:00

Can anyone please tell me the XML structure for sub-items that jqgrid uses. I’ve

  • 0

Can anyone please tell me the XML structure for sub-items that jqgrid uses. I’ve read the documentation and it does not explain clearly how one would create a tree view with sub-items in it. Basically I have a 2 column grid with 3 levels.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T16:36:53+00:00Added an answer on May 11, 2026 at 4:36 pm

    From the demo:
    http://www.trirand.com/jqgrid35/jqgrid.html

    (under new in version 3.3->tree grid)

    It makes this ajax call as a post:
    http://www.trirand.com/jqgrid35/server.php?q=tree

    The post parameters looks like:

    _search: false
    n_left: 1
    n_level: 0
    n_right: 8
    nd: 1241000465087
    nodeid: 1
    page: 1
    rows: 20
    sidx    
    sord: asc
    

    Which returns exactly this:

    <?xml version='1.0' encoding='utf-8'?>
    <rows>
    <page>1</page>
    <total>1</total>
    <records>1</records>
    <row><cell>1</cell><cell>Cash</cell><cell>100</cell><cell>400.00</cell<cell>250.00</cell><cell>150.00</cell><cell>0</cell><cell>1</cell><cell>8</cell><cell>false</cell><cell>false</cell></row>
    <row><cell>5</cell><cell>Bank's</cell><cell>200</cell><cell>1500.00</cell><cell>1000.00</cell><cell>500.00</cell><cell>0</cell><cell>9</cell><cell>14</cell><cell>false</cell><cell>false</cell></row>
    <row><cell>8</cell><cell>Fixed asset</cell><cell>300</cell><cell>0.00</cell<cell>1000.00</cell><cell>-1000.00</cell><cell>0</cell><cell>15</cell><cell>16</cell><cell>true</cell><cell>false</cell></row>
    </rows>
    

    For each sub row it makes another ajax call. The first “cell” element specifie the row number. When there is a gap before the next row id, it knows that it has subitems, and will put an expander for that row. When the user selects the expander, it makes another ajax call, and the following is returned:

    <?xml version='1.0' encoding='utf-8'?>
    <rows>
    <page>1</page>
    <total>1</total>
    <records>1</records>
    <row><cell>2</cell><cell>Cash 1</cell><cell>1</cell><cell>300.00</cell><cell>200.00</cell><cell>100.00</cell><cell>1</cell><cell>2</cell><cell>5</cell><cell>false</cell><cell>false</cell></row>
    <row><cell>4</cell><cell>Cash 2</cell><cell>2</cell><cell>100.00</cell><cell>50.00</cell><cell>50.00</cell><cell>1</cell><cell>6</cell><cell>7</cell><cell>true</cell><cell>false</cell></row>
    </rows>
    

    Looking at the source, it specifies column names, and it’s expecting them to be returned in order. I’m pretty sure you can write this to not expect a particular order, but that’s how the mapping is set. This is pretty much a clone of the way ext does things, which is a good way to follow because they do it well.

    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"
    });
    

    And, for completeness, lets include the PHP source example (went through this much trouble, might as well finish it off!):

    $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>";     
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can i get the source code for a WAMP stack installer somewhere? Any help
I need to solve the following question which i can't get to work by
If all tables I want to delete from have the column gamer_id can i
I want to use a temp directory that will be unique to this build.
Every time that I want to do a Layout, I'm getting a black layout
I have a new web app that is packaged as a WAR as part
I'm trying to build a C++ extension for python using swig. I've followed the
I'm in the process of porting some code from Linux to Mac OS X.
i have a input tag which is non editable, but some times i need
We manage a site for a medical charity. They have a number of links

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.