Refresh a row after CRUD

hello,
how to refresh and expand a specific row in a treegrid  after a CRUD.
the datasource of treegrid is a type remote data:
this.dataTree = new DataManager( DataMangerOption.getTreeDataManger({},
Compte.ENDPOINT_PLURAL,['code', 'name', 'id', 'level(id)',
'affiliateAccount','budgetLine'],
Compte.ENDPOINT_PLURAL, 'affiliateAccount',{
sort: 'code,asc',
filter: ` (level.project.uid;${Operator.EQUAL};'${id}')`
}),

);

3 Replies

MP Manivannan Padmanaban Syncfusion Team May 15, 2020 07:29 AM UTC

Hi Mamadou, 

Greetings from Syncfusion Support. 

From the shared query, we are able to understand that you want to expand the specific row after CRUD action. Using expandRow method of Tree Grid in actionComplete event we have achieved your requirement. Refer to the below code example, 

<ejs-treegrid #treegrid  
[dataSource]='data' (actionComplete) ="Complete($event)" [treeColumnIndex]='1'> 
  <e-columns> 
………………… 
  </e-columns> 
</ejs-treegrid> 
  

import { Component, ViewChild, ViewEncapsulation, OnInit, Inject } from "@angular/core";import { Column, EditSettingsModel, ToolbarItems, TreeGridComponent } from "@syncfusion/ej2-angular-treegrid";……………………. ………………export class FetchDataComponent {…………………….  @ViewChild('treegrid')  public treegrid: TreeGridComponent;     Complete = function (args: any) {    if (args.requestType === 'save') { // check the request type here.      this.treegrid.expandRow(this.treegrid.getRowByIndex(0)) // pass your desire row here using index.    }  }    }


Also, refer to the below API links. 

Regards, 
Manivannan Padmanaban 



MA mamadou May 15, 2020 02:54 PM UTC

Hello,
Thanks for your feedback
it is possible to refresh a specifique row of treegrid?
I would like to refresh only one line instead of treegrid.



MP Manivannan Padmanaban Syncfusion Team May 18, 2020 10:49 AM UTC

Hi Mamadou, 

Thanks for the update. 

Using updateRow method of tree grid, we can able to refresh the specific row. Refer to the below code example, 


<ejs-treegrid #treegrid ……..' 
……………. (actionComplete) ="Complete($event)" [treeColumnIndex]='1'> 
  <e-columns> 
    <e-column field='TaskID' headerText='Task ID' isPrimaryKey=true width='150'></e-column> 
    <e-column field='TaskName' headerText='Task Name' width='150'></e-column> 
    ………….. 
  </e-columns> 
</ejs-treegrid> 

export class FetchDataComponent {  ………….  @ViewChild('treegrid')  public treegrid: TreeGridComponent;………….   Complete = function (args: any) {    if (args.requestType === 'save') {………………………..      var data = this.treegrid.getCurrentViewRecords()[1] // get the desire data from current view records using index value.      data.taskName = "update"// do the changes.      this.treegrid.updateRow(1, data); // modify the specific row using updateRow method by passing index and modified data.    }  }    }


Also, refer the below API link. 

If your requirement is not fulfilled by the shared solution, please get back to us with the thorough explanation that will help us achieve your requirement as soon as possible. 

Regards, 
Manivannan Padmanaban 


Loader.
Up arrow icon