I am using the IgTreeGrid with rowvirtualization, paging, TreeHierarchicalDataSource ++, for angularjs.
I am having trouble with a couple of things, that I would expect to be basic functionality.
Like adding/updating row and immediately display the changes in the view and the grid having the edited row as selected and visible.
It looks like the virtualScrollTo scrolls to the index of a row, how do I get the index by an Id?And how do I scroll to it if it's on a different page? I know I can change page but not how to get pageindex by a row Id.
I have created a jsfiddle to demonstrate the issues: http://jsfiddle.net/onf7fqur/4/
Looking forward to see the solution
In your sample you are updating the data source only, you will have to introduce the changed data source into the treegrid - $("#grid").igTreeGrid("dataBind");
The virtualScroll API method is scrolling to the row index when you are passing number as argument, https://www.igniteui.com/help/api/2017.1/ui.iggrid#methods:virtualScrollTo
I would match the row identifier to row index. So a combination pageSize, currentPageIndex and virtualScrollTo API will allow you to easily achieve your scenario.
Please review the modified fiddle and let us know if you have further questions.
Hi thanks for you're reply,
But you're solution would not work in any other case than where the Id equals the index, and not if the user filter or changes sort order (index would not equals id).
I still can't see a way to scoll to a given row. It's a bit strange that you're api requires an input of an index when there is no api method to get row index.
One solution would be if there was an option like : $("#grid").data("igTreeGrid").dataSource.dataView();
Where I could loop through that list and then find the Id. Except that this one would not work if the result spans over multiple pages as it only returns data from current page.
Is there also a reason why you are calling the grid api instead of the datasource api, what's the point of the datasource api when you can do it directly through the grid api?
Looking forward to get a solution soon, as you say this can be easily achieved :)
My suggestion is not working in cases of reordering rows. If you need the features you mentioned, you need to create a functionality which extracts the index based on the id of the treegrid.
And the solution you are looking is to use: $("#grid").data("igTreeGrid").dataSource.data() when no filtering is applied and $("#grid").data("igTreeGrid").dataSource.filteredData() when there is a filter applied on the data.
Using the grid API would update the grid UI and datasource. Using dataSouce API would update only the datasource and you need to manually call dataBind to update the grid UI.