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

Grid can't change grouping when field name changed

Hi,

I try to change field name and group name but I get error message "Cannot set properties of undefined (setting 'visible')". Do you have another way to change field name and group name at same time?


Sample link: https://stackblitz.com/edit/angular-poiffy-3bgegu?file=app.component.ts


Thank you


1 Reply 1 reply marked as answer

JC Joseph Christ Nithin Issack Syncfusion Team February 17, 2023 05:00 PM UTC

Hi Krailit,


  Greetings from Syncfusion support.


  Based on your query, you want to change the filed name and the grouped column. Your requirement can be achieved by clearing the grouping first by using the `clearGrouping` method and then you can change the filed name by getting the column using the `getColumnByField` and group the column again by using the `groupColumn` method.


Refer the below code example:


 

btnClick() {

    this.grid.clearGrouping();

    var column = this.grid.getColumnByField('OrderID');

    column.field = 'EmployeeID';

    this.grid.refreshColumns();

    setTimeout(() => {

      this.grid.groupColumn('EmployeeID');

    }, 100);

  }

 


Thanks,

Joseph I.


Marked as answer
Loader.
Up arrow icon