Knockout-Contrib / Knockout-Contrib/KoGrid
Bug sorting columns with a multiselect grid
- Dominant language
- JavaScript
- Stars
- 277
- Forks
- 124
- PR merge metrics
- No merged PRs in 30d
Description
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);
}
}
};
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in selectionService.js and reproduce the multiselect grid scenario with sorting enabled: select a row, sort a column, and inspect selectedItems. Verify that sorting does not lose the selected row and that deselection still behaves correctly; the issue includes the proposed guard to evaluate.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100