Ngx-datatable: Use columns array with a checkbox

Created on 15 Jan 2018  路  5Comments  路  Source: swimlane/ngx-datatable

I'm submitting a ... (check one with "x")

[ ] bug report => search github for a similar issue or PR before submitting
[x] feature request
[ ] support request => Please do not submit support request here, post on Stackoverflow or Gitter

Current behavior
Right now, if you want to add a checkbox, you have to add a column manually. If you do this with a dynamic column list, you either get exactly one column (the checkbox only) or your data, not both.

Expected behavior
I would like to specify a property that just pre-pends a checkbox field on the table, without adding it to the HTML template.

What is the motivation / use case for changing the behavior?
I have dynamic columns (people can choose what columns they want to see/edit), and I want them to also be able to multi select entries in the table.

  • Table version: 11.1.7

  • Angular version: 5.0.3

  • Browser: all

  • Language: all

Most helpful comment

Although not clear from the documentation, you can add a checkbox column from the component class without having the columns defined in the template.

I've setup an example: https://stackblitz.com/edit/angular-klbxfe?file=app%2Fapp.component.ts

All 5 comments

Although not clear from the documentation, you can add a checkbox column from the component class without having the columns defined in the template.

I've setup an example: https://stackblitz.com/edit/angular-klbxfe?file=app%2Fapp.component.ts

Thanks, I had no idea.

Although not clear from the documentation, you can add a checkbox column from the component class without having the columns defined in the template.

I've setup an example: https://stackblitz.com/edit/angular-klbxfe?file=app%2Fapp.component.ts

The link is broken, do you have another reference about how to do this?

@jftsaraiva
it's "findable" in the documentation:
https://swimlane.gitbook.io/ngx-datatable/api/column/inputs#checkboxable-boolean

I've also setup a new stackblitz project as an example:
https://stackblitz.com/edit/angular-luus1e?file=src%2Fapp%2Fapp.component.ts

Thanks,

I was looking for something different, I thought this example was about that. I need to show a checkbox in a boolean column instead of text: true / false.
I'm trying to use cellTemplate, but as I load my definition from a .json file (in assets) I can't use cellTemplate: this.templateX.
I was hoping that this example was about that, unfortunately it is not. But thanks anyway.

Was this page helpful?
0 / 5 - 0 ratings