dataStateChange on kendo-grid-column-chooser

2 Answers 1266 Views
Grid
Bob
Top achievements
Rank 1
Iron
Iron
Iron
Bob asked on 06 Aug 2021, 12:43 PM | edited on 06 Aug 2021, 12:44 PM

Hi Guys,

Why does the kendo-grid-column-chooser component not fire dataStateChange so any changes to selected columns can be persisted?

 

On my grid I have the following command:

(dataStateChange)="dataStateChange($event)"

And I have even tried:

<kendo-grid-column-chooser (dataStateChange)="dataStateChange($event)" class="pull-right"></kendo-grid-column-chooser>

But neither command fires dataStateChange from the column chooserIs there a solution to this?

Cheers,
Bob

2 Answers, 1 is accepted

Sort by
0
Yanmario
Telerik team
answered on 10 Aug 2021, 11:37 AM

Hi Bob,

Thank you for the provided code snippets.

In general, the DataStateChange event fire when the data state of the Grid is changed, and the event is only available to the Grid component as the ColumnChooserComponent doesn't have any events. When the ColumnChooserComponent is used, the columnVisabilityChange event will fire when the user changes the columns' visibility. The event also provides information about the hidden columns as demonstrated in the following StackBlitz example:

https://stackblitz.com/edit/angular-1rhvbe?file=app/app.component.ts

I hope this helps.

Regards,
Yanmario Menev
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Bob
Top achievements
Rank 1
Iron
Iron
Iron
answered on 10 Aug 2021, 12:10 PM | edited on 10 Aug 2021, 12:10 PM

Hi Yanmario,

Perfect answer, I was able to use the columnVisibilityChange event to persist newly selected and deselected columns:

  columnChange(e: ColumnVisibilityChangeEvent) {
    e.columns.forEach((column) => {
      let columnConfig = _.find(this.gridSettings.columnsConfig, m => m.title === column.displayTitle); 
      columnConfig.hidden = column.hidden;
    })
    this.saveGridSettings(this.grid);
  }
Cheers,
Bob

 

 

Yanmario
Telerik team
commented on 10 Aug 2021, 01:01 PM

Hi Bob,

I'm happy to hear that the provided information helped you achieve the application requirment and indeed, the provided code snippet solution looks good.

Regards,
Yanmario Menev
Progress Telerik

Tags
Grid
Asked by
Bob
Top achievements
Rank 1
Iron
Iron
Iron
Answers by
Yanmario
Telerik team
Bob
Top achievements
Rank 1
Iron
Iron
Iron
Share this question
or