Hi,
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() ???
You should know, the dataSource.length is 2, and the treegrid.getCurrentViewRecords() .length is 3.
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
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
I don't know which should be updated.
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
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 ?
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
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
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
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 index: number = 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
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.
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