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

Add dynamic column in table with editable headers

I want to create a table where user can add dynamic columns on Add button click shown in attached below pic and also can edit header names. In the table 1st column would be fixed default input text and remaining all would be checkbox columns which will be dynamically added on button click every time.



4 Replies

VB Vinitha Balasubramanian Syncfusion Team February 27, 2023 06:00 PM UTC

Hi Mukarram,


Greetings from Syncfusion support.


Query: Add dynamic column in table with editable headers


Based on your query, we understand that you want to edit the header values in the EJ2 Grid. However, we regret to inform you that our Grid component does not support editing of header values.


Regards,

Vinitha Balasubramanian



MA Mukarram Ali March 2, 2023 01:58 PM UTC

what about 2nd part of above query i.e.  user can add dynamic columns on Add button click shown in attached above pic.
In the table 1st column would be fixed default input text and remaining all would be checkbox columns which will be dynamically added on button click every time.



MA Mukarram Ali March 15, 2023 12:59 PM UTC

my query is still open. Could you please look into it(above comment).



RS Rajapandiyan Settu Syncfusion Team March 20, 2023 09:31 AM UTC

Hi Mukarram,


By using the following code, you can dynamically add columns to the Grid component through the button click.


refreshColumns: https://ej2.syncfusion.com/angular/documentation/api/grid/#refreshcolumns
getColumnByField: https://ej2.syncfusion.com/angular/documentation/api/grid/#getcolumnbyfield

 

  btnClick1(args) {

    if (this.grid.getColumnByField('Verified1') == null) {

      // push the new column to the Grid’s Columns

      this.grid.columns.push({

        field: 'Verified1',

        width: 120,

        displayAsCheckBox: true,

      } as any);

      // refresh the Grid columns

      this.grid.refreshColumns();

    }

  }

 


Sample: https://stackblitz.com/edit/angular-kavrgs?file=src%2Fapp.component.ts

Regards,

Rajapandiyan S


Loader.
Live Chat Icon For mobile
Up arrow icon