md-data-table
md-data-table copied to clipboard
Toggle md-row-select
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.
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.
@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.
+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.
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">
I've had more luck simply with the ng-disabled="shouldDisable"
attribute. md-disable-select
didn't work for me.