dataView.onRowsChanged event doesn't always fire when the rows have changed
See original GitHub issueIssue Description
When filtering rows, the dataView
’s onRowsChanged
event does not always get called when the rows have changed. This happens when filtering down the list such that the new rows are the first X rows from the current rows.
For example:
Your data consists of three records in this order: “Task 01”, “Task 02”, “Task 03”
When filtering on rows with a “0”, the onRowsChanged
event correctly does not fire because all 3 rows are still there.
If I then filter to “01”, the onRowsChanged
event still does not fire even though only 1 row is now showing.
Had I filtered on “02”, the onRowsChanged
event would have fired.
The issue lies in how the dataView
checks for row changes in its getRowDiffs
function. At a basic level, this function loops through the newly filtered rows and compares them to the rows before the new filter. As long as the new rows exist in the the original rows in the same order, the function does not report any diffs. It is ignoring that the original row list contains more rows than the new list. All of these additional rows should be considered diffs.
The getRowDiffs
function affects the onRowsChanged
event because dataView.refresh()
calls recalc()
which ultimately returns an array of row indexes that changed via the getRowDiffs
function. The refresh
function will only fire the onRowsChanged
event if getRowDiffs()
reports any diffs.
Here is a JSFiddle illustrating this issue: https://jsfiddle.net/bcnap2dm/
I used the code from this example as a starting point: http://6pac.github.io/SlickGrid/examples/example4-model.html
From there, all I did was simplify the data set and add toastr notifications to show when the onRowsChanged
event is triggered.
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (5 by maintainers)
Look, my apologies for this. My thoughts are that I should update my Wiki quite broadly (it hasn’t changed since MLeibman). It’s been on the TODO list for some time. I’ve just been too busy. Will try to get something up in the next month. Anyone is welcome to document it and make a pull request to the Wiki … 😃
https://github.com/6pac/SlickGrid/issues/344