Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example9 row-reordering can corrupt lists #300

Closed
ajrnz opened this issue Mar 8, 2012 · 1 comment
Closed

Example9 row-reordering can corrupt lists #300

ajrnz opened this issue Mar 8, 2012 · 1 comment

Comments

@ajrnz
Copy link

ajrnz commented Mar 8, 2012

To reproduce. Add 12 items to the grid. Select items 8,9,10, Move to above position 7. The list will in grow by one item.

This is a problem in onMoveRows and is due to lexical instead of numeric sorting. In the example above row 10 will be sorted before 8 & 9 which is a problem for the splices below. The code below corrects the problem. It also fixes a misordering problem when moving multiple rows

...
var insertBefore = args.insertBefore;
left = data.slice(0, insertBefore);
right = data.slice(insertBefore, data.length);

// Put in table order - the selection doesn't guarantee this 
rows.sort(function(a,b){return a-b});

for (var i = 0; i < rows.length; i++) {
  extractedRows.push(data[rows[i]]);
}

// Need to sort reverse numerically or else the splices below fail badly
rows.reverse();

for (var i = 0; i < rows.length; i++) {
  var row = rows[i];
  if (row < insertBefore) {
    left.splice(row, 1);
...
@mleibman
Copy link
Owner

Good catch!

stolenng pushed a commit to bringg/SlickGrid that referenced this issue Aug 19, 2019
…otify

fixes issue mleibman#299, notify onGroupChanged even on empty array
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants