How to push new column to grid as an ng-template

Hello,

I am using a Grid component inside of a Tab component, and I'm having trouble figuring out how to add multiple columns as needed when the grid is being used in this way. There are a varying number of possible tabs, each with their own grid that needs to be updated accordingly. They all pull their data from the same Observable object using a different key for each that corresponds to the name of the tab. I would like the new columns to be added to all grids whenever the observable updates. How can I accomplish this? Am I approaching this the correct way in the first place?





1 Reply

PS Pavithra Subramaniyam Syncfusion Team September 29, 2022 07:09 AM UTC

Hi Jay Bauer,


Thanks for contacting Syncfusion support.


You can update the columns inside the “dataBound” event when every time the grid dataSource is changed. You can set the “columns” property and call the “refreshColumns” method. Please refer to the below code example for more information.


dataBound() {

  // here you can add your conditions

  if (this.isdataChanged) {

    this.grid.columns = [{ field: 'Verified' }];

    this.isdataChanged = false;

    this.grid.refreshColumns();

  }

}

 


If the above doesn’t meet your requirement, please share a simple sample that will be helpful for us to provide a better solution as early as possible.


Please get back to us if you need further assistance on this.


Regards,

Pavithra S


Loader.
Up arrow icon