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

Bug sorting columns with a multiselect grid #316

Open
MarcoSe82 opened this issue Jul 6, 2017 · 1 comment
Open

Bug sorting columns with a multiselect grid #316

MarcoSe82 opened this issue Jul 6, 2017 · 1 comment

Comments

@MarcoSe82
Copy link

Hi, I've a bug with a multiselect: true and enableSorting: true koGrid.
For example: if the grid have multiple rows, I select one and than I order by a column, it seems that the selectedItems array lost the row.
I think that the problem is on the selectionService.js,

self.setSelection = function(rowItem, isSelected) {
        rowItem.selected(isSelected) ;
        rowItem.entity[SELECTED_PROP] = isSelected;
        if (!isSelected) {
            var indx = self.selectedItems.indexOf(rowItem.entity);
            self.selectedItems.splice(indx, 1);
        } else {
            if (self.selectedItems.indexOf(rowItem.entity) === -1) {
                self.selectedItems.push(rowItem.entity);
            }
        }
    };

should be:

self.setSelection = function(rowItem, isSelected) {
        rowItem.selected(isSelected) ;
        rowItem.entity[SELECTED_PROP] = isSelected;
        if (!isSelected) {
        	var indx = self.selectedItems.indexOf(rowItem.entity);
		if (indx === -1) {
			return;
		}
            self.selectedItems.splice(indx, 1);
        } else {
            if (self.selectedItems.indexOf(rowItem.entity) === -1) {
                self.selectedItems.push(rowItem.entity);
            }
        }
    };
@ghost
Copy link

ghost commented Feb 7, 2018

+1 Just found this bug trying to preselect items on component initialization.

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

1 participant