Checkbox for auto generated columns

Hi,

I have tried to implement checkboxes to Grid with auto generated columns.
By doing it like this:

this.tableService.model$.subscribe((x) => {
x.map((y) => (y['checkbox'] = false));
});

and :

if ((cols as any).field === 'checkbox')
{
            cols['type'] = 'checkbox';
     }

And I have defined the datasource as such.

[dataSource]="tableService.model$ | async"

But the unselect doesn't work and the "Select/Unselect All" doesn't update.



1 Reply 1 reply marked as answer

JC Joseph Christ Nithin Issack Syncfusion Team November 15, 2022 03:09 PM UTC

Hi Gustav,


  Greetings from Syncfusion support.


  Based on your query, you want to add a checkbox column along with the autogenerated columns.  Your requirements can be achieved by using the dataBound event of the EJ2 Grid.


Refer the below code example.


 

dataBound(args) {

    if (this.addColumn) {

      var obj = { type: 'checkbox', width: 50 };

      this.grid.columns.unshift(obj as any);

      this.addColumn = false;

      this.grid.freezeRefresh();

    }

  }

 


Sample: https://stackblitz.com/edit/angular-3jnvx9-bkudts?file=app.component.html,app.component.ts


Regards,

Joseph I.


Marked as answer
Loader.
Up arrow icon