We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

ejTreeGrid does not maintain nodes state (collapsed/expanded) after updating data source list

I have an ejTreeGrid whose item source is binded by knockout to an observable array. Whenever I update the array by adding or removing an element the state of the treegrid nodes is not maintained. All the nodes are expanded.
How can I prevent the nodes to be expanded every time?

This is my grid definition where 'assets' is the observable array.

<div id="assetsGrid" data-bind="ejTreeGrid: {
                               dataSource: assets,
                               idMapping: 'Id',
                               parentIdMapping: 'ParentId',
                               selectedRowIndex: selectedAssetGridRow,
                               enableVirtualization: true,
                               isResponsive: true,
                               enableResize: true,
                               rowHeight: 48,
                               enableCollapseAll: false,
                               columns: [{ field: 'Code', headerText: 'Code', width: 200, verticalAlignment: 'center' },
                                         { field: 'Description', headerText: 'Description' },
                                         { field: 'WrcName', headerText: 'Wrc' },
                                         { field: 'MaterialCode', headerText: 'Material Code' },
                                         { field: 'ExternalMaterialCode', headerText: 'Ext Material Code' },
                                         { headerText: 'Docs', isTemplateColumn: true, templateID: 'viewDocsColumnTemplate', textAlign: 'center', width: 50 }
                                       ],
                               toolbarSettings: {
                                   showToolbar: true,
                                   toolbarItems: [
                                        ej.TreeGrid.ToolbarItems.Add,
                                        ej.TreeGrid.ToolbarItems.Edit,
                                        ej.TreeGrid.ToolbarItems.Delete,
                                        ej.TreeGrid.ToolbarItems.ExpandAll,
                                        ej.TreeGrid.ToolbarItems.CollapseAll
                                   ]
                                 },
                                editSettings: {
                                    allowEditing: true,
                                    allowDeleting: true
                                },
                                toolbarClick: toolbarClick,
                                rowDataBound: assetRowDataBound
                              }">
</div>

5 Replies

JS Jonesherine Stephen Syncfusion Team February 11, 2017 05:29 AM UTC

Hi Cristian, 
At present there is no support for expand Mapping in Tree Grid. Please follow-up with the incident which is created under your account to track the status of this feature.
Regards,
 
Jone sherine P S 



UY Ugur Yilmaz November 20, 2017 02:59 PM UTC

is there a solution for this incident? 


SR Suriyaprasanth Ravikumar Syncfusion Team November 21, 2017 12:27 PM UTC

Hi Ugur, 

As per your request, we have provided support for expand Mapping in TreeGrid, it already get included in our Essential studio version “15.2.0.40”, please upgrade your source version to “15.2.0.40” or greater than this to use this feature. 
Please refer the code snippet below. 
[HTML] 
    
<div id="TreeGrid" data-bind="ejTreeGrid:{ expandStateMapping:'isExpand' ... }" style="width:100%;height:450px;"> 
    //.. 
</div> 
 
var sampleData = [ 
      { 
          taskID: 1,  ... ,subtasks: [   ...   ]  
      }, 
      { 
          taskID: 6,  ...  ,isExpand: false,subtasks: [   ...   ] 
      }, 
         //..           
    ]; 
 
We have also prepared a sample for your reference, Please find the sample link below. 

Thanks, 
Suriyaprasanth R 



UY Ugur Yilmaz November 23, 2017 08:56 AM UTC

perfect. you saved my day :) thanks.


SR Suriyaprasanth Ravikumar Syncfusion Team November 24, 2017 11:20 AM UTC

Hi Ugur, 

Thank you for your update. We are glad that your requirement has been achieved.  

Thanks, 
Suriyaprasanth R 


Loader.
Up arrow icon