question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

dataView.onRowsChanged event doesn't always fire when the rows have changed

See original GitHub issue

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:closed
  • Created 7 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
6paccommented, Mar 18, 2017

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 … 😃

0reactions
6paccommented, Feb 23, 2019
Read more comments on GitHub >

github_iconTop Results From Across the Web

Dataview "Row Changed/Row Changing" event not "firing" on ...
I am trying to perform a task based up an item being added or deleted from a grid/view. Below is my setup. Seems...
Read more >
DataGridView Row update event - Stack Overflow
Fire an event when user finish change a row. So while the user is editing the same row it memorizes the current row...
Read more >
Handling DataView Events - ADO.NET - Microsoft Learn
You can use the ListChanged event of the DataView to determine if a view has been updated. Updates that raise the event include...
Read more >
Using a DataView | Working with DataSets - InformIT
Just as with the DataSet class, the DataView class exposes a single event, in this case, called ListChanged. This event is fired anytime...
Read more >
GridView FocusedRowChanged New Row Handle
When we click to a different row, this event fires once, and doesn't recognize the new row as a valid row. We get...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found