KoGrid icon indicating copy to clipboard operation
KoGrid copied to clipboard

Bug sorting columns with a multiselect grid

Open MarcoSe82 opened this issue 8 years ago • 1 comments

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);
            }
        }
    };

MarcoSe82 avatar Jul 06 '17 07:07 MarcoSe82

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

ghost avatar Feb 07 '18 11:02 ghost