2
votes

I am using ng2-smart-table in my project, I want to add a column with checkboxes which while rendering will be checked based on the object which binds the table. In the object, there is a field with a boolean value which will determine if the checkbox will be checked or not, and after making changes in the checkboxes, the changed values should be available.

2

2 Answers

2
votes

You need to set filter type checkbox

passed: {
    title: 'Passed',
    filter: {
      type: 'checkbox',
      config: {
        true: 'Yes',
        false: 'No',
        resetText: 'clear',
      },
    },
  },

in your data you need to pass checkbox value

data = [
{
  id: 4,
  name: 'Patricia Lebsack',
  email: '[email protected]',
  passed: 'Yes',
},
]

Try this example Checkbox, Select and Completer filter types

0
votes

I can not provide you a full sample code right now but you should define a column for your checkbox. Provide a boolean value for that column. Don't forget to add

'type: custom'

It renders the Component you provide. I used a component named MyCheckboxComponent

<nb-checkbox [ngModel]="selected"></nb-checkbox>

nb-checkbox is in nebular library.

settings = {
    columns: {
        checkBox: {
          type: 'custom',
          filter: false,
          width: '10px',
          renderComponent: MyCheckboxComponent
    }
  }
}