Skip to content

Commit

Permalink
Added support for selectableCount option.
Browse files Browse the repository at this point in the history
  • Loading branch information
harbulot committed Feb 10, 2022
1 parent 6755cc6 commit 072645b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/js/modules/SelectRow/SelectRow.js
Expand Up @@ -12,6 +12,7 @@ class SelectRow extends Module{
this.headerCheckboxElement = null; // hold header select element

this.registerTableOption("selectable", "highlight"); //highlight rows on hover
this.registerTableOption("selectableCount", true); //max number of selectable rows
this.registerTableOption("selectableRangeMode", "drag"); //highlight rows on hover
this.registerTableOption("selectableRollingSelection", true); //roll selection once maximum number of selectable rows is reached
this.registerTableOption("selectablePersistence", true); // maintain selection when table view is updated
Expand Down Expand Up @@ -247,8 +248,13 @@ class SelectRow extends Module{
var index;

//handle max row count
if(!isNaN(this.table.options.selectable) && this.table.options.selectable !== true && !force){
if(this.selectedRows.length >= this.table.options.selectable){
var selectableCount = this.table.options.selectable;
// For compatibility, we check table.options.selectable first.
if (isNaN(selectableCount) || selectableCount === true) {
selectableCount = this.table.options.selectableCount;
}
if(!isNaN(selectableCount) && selectableCount !== true && !force){
if(this.selectedRows.length >= selectableCount){
if(this.table.options.selectableRollingSelection){
this._deselectRow(this.selectedRows[0]);
}else{
Expand Down

0 comments on commit 072645b

Please sign in to comment.