angular-data-table icon indicating copy to clipboard operation
angular-data-table copied to clipboard

selectable without multiSelect results in selected attribute not being set

Open JonathanThorpe opened this issue 9 years ago • 0 comments

It would appear that when using selectable without multiSelect (i.e. select one item at at time in the table), the variable bound using the dtable's selected attribute doesn't get populated.

In SelectionController.js under SelectRow, it appears that the following code has no effect: this.selected = row

Most likely because Angular doesn't like us changing what the directive's attribute is referencing.

As a quick and dirty workaround, I was able to change this to:

} else {
        this.selected.length = 0;
        this.selected.push(row);
        this.body.onSelect({ rows: [ row ] });
}

I had to do this.selected.length = 0; to avoid destroying the array and creating a new one - I just wanted to empty it.

And in BodyController.js' isSelected, change this to:

isSelected(row){
    var selected = false;

    if(this.options.selectable){
      selected = this.selected.indexOf(row) > -1;
    }
    return selected;
  }

Not sure how this should be fixed permanently, but this worked for me.

Modifying the selection demo shows this issue: http://codepen.io/jthorpe/pen/MJWxzY

In effect, rows don't get highlighted either (which was more of a problem for me).

JonathanThorpe avatar Jan 04 '17 11:01 JonathanThorpe