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

Toggle md-row-select

Open shader opened this issue 9 years ago • 5 comments

I want to turn the checkbox column visibility on and off, but I haven't figured out how.

I tried removing the md-row-select attribute, which is responsible for generating it in the first place, but it didn't have any effect.

shader avatar Jul 31 '15 20:07 shader

Removing md-row-select should remove the checkboxes. If this is not the case then I most likely broke something in version 0.8.0. I've been moving all day but tommorow hopefully I will have time to fix this.

daniel-nagy avatar Aug 01 '15 00:08 daniel-nagy

@shader removing the md-row-select attribute indeed removes the checkboxes. I suspect you want to conditionally enable row selection?

This is an interesting problem. In order for the directive to evaluate an expression, checkbox creation will need to be deferred until the linking phase and then recompiled. One issue; however, is once compiled the truthfulness of the expression may change. At which point the checkboxes will need to be either removed or added accordingly. We need to keep in mind security, so we can't just use ng-if or ng-show on a checkbox because it is not difficult for someone to open the developer tools and tamper with the template. In addition, we need to keep performance in mind as modifying the template and recompiling every time the expression changes may be costly.

I have an idea as to how to go about this but it may be sometime before I get a chance to implement this.

daniel-nagy avatar Aug 01 '15 18:08 daniel-nagy

+1 I have a use case in which I want to disable check boxes if a user is not an administrator. I tried using ng-attr + md-row-select and could not get it to work.

We need to keep in mind security, so we can't just use ng-if or ng-show on a checkbox because it is not difficult for someone to open the developer tools and tamper with the template.

It's only slightly more difficult to send a tampered AJAX request. Client-side data validation !== security.

mjhasbach avatar Oct 21 '15 03:10 mjhasbach

You can use the "md-disable-select" attribute to disable the selection of a row.

<tr md-disable-select="!auth.admin" md-auto-select ng-repeat="element in elements">

elgambet avatar Jul 12 '16 18:07 elgambet

I've had more luck simply with the ng-disabled="shouldDisable" attribute. md-disable-select didn't work for me.

david-err avatar Aug 24 '17 15:08 david-err