0

ON select row i m calling

   $('#grid').trigger('reloadGrid');

after which when the grid reloads, i want this node expanded and show children. i tried doing somethinglike

var rootNode = $('#grid').jqGrid('getRowData')[0];
           $('#grid').jqGrid('expandRow'   ,rootNode);
           $('#grid').jqGrid('expandNode'  ,rootNode);  
           $('#grid').jqGrid('setSelection',rootNode.id);   

But this doesnt seem like working, Any Help is appreciated.

My grid object is as below

    var grid = $('#grid').jqGrid({
        treeGrid: true,
        treeGridModel: 'adjacency',
        ExpandColumn: 'businessAreaName',
        ExpandColClick : false,
        url:'/records.do',
        datatype: 'json',
        mtype: 'GET',
        colNames:['Id'
                  , 'Business Area'
                  , 'Investment'                  
                  ],
        colModel:[
/*00*/          {name:'Id',index:'Id', width:0, editable:false,hidden:true},
/*01*/          {name:'businessAreaName',index:'businessAreaName', width:160, editable:false}

        ],
        treeReader : {
            level_field: 'level',
            parent_id_field: 'parent', 
            leaf_field: 'leaf',
            expanded_field: 'expanded'
        },
        autowidth: true,
        height: 240,
        pager: '#pager',
        sortname: 'id',
        sortorder: 'asc',
        caption:'ATP ScoreCard',
        emptyrecords: 'Empty records',
        loadComplete: function() {
            designtable();          
        },
        jsonReader : {
            root: 'rows',
            page: 'page',
            total: 'total',
            records: 'records',
            repeatitems: false,
            cell: 'cell',
            id: 'agileProgrammeId'
        },
        beforeProcessing : function(data, status, xhr){
            }
        }
    });
komal salvi
  • 33
  • 1
  • 6

1 Answers1

1

First of all there are hidden expanded column which you can fill in the (see here and here). So if you include the children of the node which you need to open directly after the to opened node and set expanded: true in its properties the tree node will be displayed opened.

It can be that you want to trace which nodes opens the user and restore the nodes at the next visit of the same page. In the case I would forward you to the answer and to this one.

Community
  • 1
  • 1
Oleg
  • 220,925
  • 34
  • 403
  • 798
  • Hi Oleg, I have already set that in my DTO at the server side.... expanded:true, But it still doesnt work. On expanding the node, we otherwise r making a server side call. do i need to set any other parameters on the server apart from parent, level, leaf and expanded – komal salvi Apr 13 '12 at 10:36
  • @komalsalvi: Could you append your question with JSON data returned from the server? You can use [Fiddler](http://www.fiddler2.com/fiddler2/), [Firebug](http://getfirebug.com/) or "Network" tab of Developer Tools of IE or Chrome to catch HTTP traffic. – Oleg Apr 13 '12 at 11:45
  • {"id":4501,"businessAreaName":"ABC","parent":null,"level":0,"leaf":false,"expanded":true} – komal salvi May 14 '12 at 11:01
  • @komalsalvi: If you ask a question you start a dialog. It's difficult to hold communication with one month pauses. What you posted in the last comment is only the data for the *root* node. You wanted to display some nodes expanded. So you should 1) post back from the server the data for the nodes with `"expand‌​ed":true` 2) include all children nodes of the node directly after the expanded node. So jqGrid will *not* send additional requests to the server. The first request should just contains data of all expanded nodes together with the main data. – Oleg May 15 '12 at 07:59
  • Hi Oleg, Sorry for the inconvinience caused. But i was caught up with something else and cudn't revert on this one – komal salvi May 15 '12 at 14:36