Restore grid state + sorted columns = sorting for every row insertion?
#5,733 建立於 2016年10月11日
倉庫指標
- Star
- (5,395 star)
- PR 合併指標
- (30 天內沒有已合併 PR)
描述
Please make sure each of the following is true before submitting a new issue. We are a small team with limited time and it is very difficult to manage issues if they aren't reported correctly.
- This is a bug report, not a question on how to use the grid.
Use Stack Overflow or Gitter for questions. - You have searched the open issues to see if this bug has been filed before. We don't want duplicate issues.
- You have reviewed the tutorials and documentation to ensure you are using the grid correctly. ui-grid.info
- You are using the latest version of the grid. Older versions are not patched or supported.
- You have provided steps to recreate your bug. A plunkr is even better.
When saving the grid state is applied via gridApi.saveState.restore, it appears that loading data into the grid runs the sort function each and every time a row is inserted, and then once again at the end.
The easy way to see this is to have a sort function and put a console log in it to report how many times the comparison function is hit. If sorted manually on a grid that hasn't had it's state saved yet, the number of times it hits that comparison function will be X. If you then save the grid state and come back later, restoring the grid, it seems to run a sort each time you insert a new row, which makes for a tremendous number of more times that the same comparison function will be hit as each row is being added.
Our case is one where we are supplying an array of data of course, and I realize that in the case where you are uncertain of what data is coming in and when it is done coming in, or even when we might be adding data into the array you are watching. But the behavior of applying the sort for each and every row is very onerous when dealing with large data sets.
If at a minimum the grid would go through the initial data set offered up(or in the case of async requests, only apply a sort after all data in the request is added into the data set), and if it is an array it could insert all of that data without applying any sorting, and then when it was done adding the data it could perform any sorts needed, then this would greatly improve performance in that case at least. It can then return to sorting on every added row once it has finished this initial process.
Likewise, an event firing after it has finished it's initial data load would be nice to have.