some problems about treegrid

Hi,

  1. When I add a record, code: this.treegrid.addRecord(row, 0, 'Top'), there are some fields added on the row, like "childRecords, hasChildRecords, index, level, taskData, uniqueID", are this fields important? I don't want my treegrid's binding dataset has this fields.
  2. when I use this.treegrid.updateRow(i, row), it not works.
  3. I don't understand if this row should be one of the dataSource or one of the treegrid.getCurrentViewRecords() ???

    3. When I use this.treegrid.deleteRecord("", row), it also not works.

    I don't understand if this row should be one of the dataSource or one of the treegrid.getCurrentViewRecords() ???


11 Replies

LO lorryl June 2, 2023 03:48 AM UTC

You should know, the dataSource.length is 2, and the  treegrid.getCurrentViewRecords() .length is 3.





SM Shek Mohammed Asiq Abdul Jabbar Syncfusion Team June 5, 2023 12:15 PM UTC

Hi Lorryl,


Greetings from Syncfusion support.


Please find the responses for your query below.


Query 1#: Extra properties were added in the treegrid when adding new rows.


Yes, these properties were added by default while adding records and it is necessary to perform further Tree Grid actions based on that. Upon adding a record, the properties like childRecords, hasChildMapping, index, level, taskData, uniqueID will be included automatically. These properties will be helpful if we add a record as children for the previously added record and for other data operations.


Please refer to the following documentation : https://ej2.syncfusion.com/angular/documentation/treegrid/data-binding/local-data#self-referential-data-binding-flat-data


Query 2#: UpdateRow and deleteRow method not working properly.


Unfortunately, we cannot replicate the issue from our end. The updateRow and deleteRow are working properly in treegrid.


While using updateRow methos, we can update the records only in the current view records. Whereas while using deleteRocord, we can delete any records in the dataSource irrespective of the current view records.


Note :- The record that we are updating and deleting, should be present in the DataSource.


Kindly refer to the documentation :- https://ej2.syncfusion.com/angular/documentation/treegrid/editing/row-editing#perform-crud-action-programmatically


Please refer to the API :

updateRow : https://ej2.syncfusion.com/angular/documentation/api/treegrid/#updaterow

deleteRecord : https://ej2.syncfusion.com/angular/documentation/api/treegrid/#deleterecord


Sample : https://stackblitz.com/edit/angular-mwllaf-v9d9we?file=src%2Fapp.component.ts


Query 3#: getCurrentViewRecords shows the length of aggregates in treegrid.


We cannot replicate the issue from our end. The getCurrentViewRecords shows the records count only if we bind aggregates to it.


Please refer to the sample : https://stackblitz.com/edit/angular-ikqlpx-78npbw?file=src%2Fapp.component.ts


Image :-


Kindly get back to us for further assistance.


Regards,

Shek Mohammed Asiq



LO lorryl June 13, 2023 09:03 AM UTC

I said, the treegrid's dataSource and the treegrid.getCurrentViewRecords()'s length is different. like this:

https://stackblitz.com/edit/angular-ikqlpx-qwz2qc?file=src%2Fapp.component.html

e-aggregate [showChildSummary]="true"

I don't know which should be updated.



SM Shek Mohammed Asiq Abdul Jabbar Syncfusion Team June 14, 2023 06:05 PM UTC

Lorryl,


On further validation, we have considered the reported issue (“Child aggregates row displays in current view records.”) as a bug. Thank you for taking the time to report this issue and helping us improve our product. At Syncfusion, we are committed to fixing all validated defects (subject to technological feasibility and Product Development Life Cycle) and will include the fix in our upcoming NuGet release which is expected to be rolled out on July 5th, 2023. Until then we appreciate your patience.


You can now track the status of your request, review the proposed resolution timeline, and contact us for any further inquiries through this link. 

https://www.syncfusion.com/feedback/44462/child-aggregates-row-displays-in-current-view-records


Note: To view the above feedback, kindly login into your account. 

Disclaimer: Inclusion of this solution in the weekly release may change due to other factors including but not limited to QA checks and works reprioritization.


Regards,

Shek Mohammed Asiq



LO lorryl June 20, 2023 01:48 AM UTC

So, I want to know, when  the treegrid's dataSource and the treegrid.getCurrentViewRecords()'s length is different, choose whose index using the grid's updateRow and deleteRow's function?


index of  treegrid's dataSource or index of  treegrid.getCurrentViewRecords()? which one ?



SM Shek Mohammed Asiq Abdul Jabbar Syncfusion Team June 20, 2023 02:11 PM UTC

Lorryl,


To update or delete a row, we recommend using currentViewRecords. This is because, if we perform data operations like filtering or sorting, the currentViewRecords will update dynamically. So, we suggest you to use the index from currentViewRecords.


Note : Currently, we are working on the bug with high priority, and we will inform you once it is fixed from our end. Until then we appreciate your patience.


Regards,

Shek Mohammed Asiq



SM Shek Mohammed Asiq Abdul Jabbar Syncfusion Team July 5, 2023 10:21 AM UTC

Lorryl,


Thanks for your patience.


We are glad to announce that our patch release (22.1.37) has been rolled out successfully. The issue “Child aggregates row displays in current view records.”  has been resolved in this release. To resolve the reported issue, we suggest you update the Package to 22.1.37.


Release Notes : https://ej2.syncfusion.com/angular/documentation/release-notes/22.1.36/?type=all#tree-grid


Package :  https://www.npmjs.com/package/@syncfusion/ej2-angular-treegrid



LO lorryl July 6, 2023 08:06 AM UTC

Hello,

The dataSource's length is 4, when I click the row that index is 4, how to get the row that index is 4 from the grid datasource??

Before updating, I can get the row by "treegrid.getCurrentViewRecords()[index]", but now I don't know how to get the row?

https://stackblitz.com/edit/angular-ikqlpx-qwz2qc?file=src%2Fapp.component.ts




SM Shek Mohammed Asiq Abdul Jabbar Syncfusion Team July 7, 2023 07:08 AM UTC

Lorryl,


We can get the rowData from the selected record's index by using getRowsInfo method in treegrid. We need to pass the selected tr to fetch the rowData using getRows method. Please refer to the following code snippet.

if (!instance.grid.isEdit) {

          let indexnumber = parseInt(

            (e.target as HTMLElement)

              .closest('td')

              .getAttribute('Index'as string

          );

          var row = instance.getRows()[index]; // getting selected rows

          var rowInfo = instance.getRowInfo(row); // To get the details of the selected row

          console.log('row Data Index : ' + rowInfo.rowData.index);

          console.log('selected Row index: ' + index);

 

          // how to get the row by index from dataSource??

 

          instance.selectRow(index);

          instance.startEdit(); // calling startEdit method

 


Sample : https://stackblitz.com/edit/angular-ikqlpx-kwmtsr?file=src%2Fapp.component.ts


Note : We have removed the summary rows tr from the currentViewRecords, so the rows from the UI and currentViewRecords will get mismatch.


If we misunderstood your query, kindly share more information to replicate from our end.


Kindly get back to us for further assistance.


Regards,

Shek Mohammed Asiq



LO lorryl July 14, 2023 03:55 AM UTC

Thanks for your reply. It works.


In turn, if I know the row or the row index of the datasource, how do I get the view index of the row?

Because the summary total exists.



SM Shek Mohammed Asiq Abdul Jabbar Syncfusion Team July 17, 2023 02:45 PM UTC

Lorryl,


Query :-  If I know the row or the row index of the dataSource, how do I get the view index of the row?


From your query we suspect that you need to return current view Index of the rows. You can get the details of the current view records by removing the ‘e-summaryrow’ from the rendered rows and you can pass the index of the row from either dataSource or currentVireRecords to the filtered rows.


Please refer to the following code snippet


var visibleDataRows = instance.getRows().filter(e => !e.classList.contains('e-summaryrow'));


Sample : https://stackblitz.com/edit/angular-ikqlpx-wpr8ke?file=src%2Fapp.component.ts


Image:


Kindly get back to us for further assistance.


Regards,

Shek Mohammed Asiq


Loader.
Up arrow icon