Grid dataStateChange event - change the field name in the sort object

0 Answers 81 Views
Grid
Tomas
Top achievements
Rank 1
Tomas asked on 28 Mar 2023, 04:20 PM

How can I change the sort field name in the dataStateChange event of the grid, to another fields name, and sort by that fields name?

for example, in my component the event handler:


public dataStateChange(state: AppDataStateChangeEvent): void {
  if(state.sort[0].field === 'propertyStringValue'){
    state.sort[0].field = 'propertyNumberValue';
  }
  this.view = process(this.data, this.gridState);
}


I need this because we have two seperate properties on our data objects, one is "propertyStringValue" to display a formated version, and an actual number associated with it called "propertyNumberValue". And we want to sort by "propertyNumberValue" when the sort of the "propertyStringValue" is clicked.

When I do the above, it works only on first click, but in the following clicks the state of the dir property on the sort event object does not change, and stays at the value of "asc"

No answers yet. Maybe you can help?

Tags
Grid
Asked by
Tomas
Top achievements
Rank 1
Share this question
or