We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

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.
Live Chat Icon For mobile
Up arrow icon