swimlane / ngx-datatable

✨ A feature-rich yet lightweight data-table crafted for Angular
http://swimlane.github.io/ngx-datatable/
MIT License
4.63k stars 1.68k forks source link

Table not working correctly with material design's md-checkbox #333

Open rotemx opened 7 years ago

rotemx commented 7 years ago

Bug, feature request, or proposal:

Bug

What is the expected behavior?

When using native checkboxes with Angular2-Data-Table, I can toggle columns on or off the table.

When trying to implement Angular2 Material Design's md-checkbox the first click doesn't work - the checkbox remains checked.

After the first click the checked value is opposite to the model, i.e. opposite to the native checkboxes.

I tried many ways to fix this but without luck. I don't know whether this is a bug in md-checkbox or in angular2-data-table.

In the plunker the code from the demo, and added md-checkboxes in addition to the native ones: https://plnkr.co/edit/HGUjy5

What is the current behavior?

The first click should toggle the checkbox correctly.

What is the use-case or motivation for changing an existing behavior?

it would be great to use md-checkbox with the datatable

Which versions of Angular, Material, OS, browsers are affected?

latest Angular (2.1.2) latest Angular 2 Material latest angular2-data-table

dsbert commented 7 years ago

I'm not sure what your code looks like (is there a way to view it from that plunk link?). However, I had this problem when using md-checkbox. The solution was to bind to the change event instead of the click event that you would typically use on a native checkbox.

<md-checkbox (change)="changed()"></md-checkbox>
rotemx commented 7 years ago

@dsbert thank you the workaround worked ! but it's still a bug, so I'm leaving the issue open. you can see the code here: https://plnkr.co/edit/HGUjy5

amcdnl commented 7 years ago

Sounds good.

side note: I just released a new version with checkbox selection built in, which might be what you were trying to do.

rotemx commented 7 years ago

hi, thanks for the info. any idea on how I can change the select checkbox to angular material's

? also, there's a bug when 'rows' attribute is initialized in the constructor, "cant read property length of undefined" in index.js:2154 (this.rows is undefined) but i will open a separate issue on that. On Sat, Dec 3, 2016 at 7:00 PM, Austin wrote: > Sounds good. > > side note: I just released a new version with checkbox selection built in, > which might be what you were trying to do. > > — > You are receiving this because you authored the thread. > Reply to this email directly, view it on GitHub > , > or mute the thread > > . > -- ►►Rotem Meiri rotemx@gmail.com facebook.com/rotemx
amcdnl commented 7 years ago

Plz open a ticket for that.

If you wanted to use material checkbox, just use it like you want any other custom control and handle selection yourself.