Our blazing fast Grid component built with pure JavaScript


Post by eguardiola »

Hi,

How the sort icon of a column header can be clicked programmatically?

Thanks!

Post by mats »


Post by eguardiola »

Thanks.

- I'm defining a custom sorter for the 'startDate' column.
- When i click on the sort icon the custom sorter is called and everything works well.
- When i call to store.sort('startDate') my custom sorter is not called and the sorting is wrong..

- If a call store.sort(myfuncion) with my custom sorting function the sorting works but the sort icon on the column doesn't remain pressed so the sorting is lost when the filtering is changed. That's why i'm trying to click the sorting icon button programmatically because when i click it by hand all works as i need.

¿Any tip?

Post by mats »

- When i call to store.sort('startDate') my custom sorter is not called and the sorting is wrong..
Why would you expect
store.sort('startDate')
to call your sorter? store.sort('foo') sorts by the data field 'foo'.

Can you please provide a simple test case and we'll try to help

Post by eguardiola »

I mean that if in the column config you provide a custom sorting function in the sortable property this function is called when you click on the sort icon of the header but is not called when you call it by code: store.sort('foo')

https://bryntum.com/docs/scheduler/#Grid/column/Column#config-sortable

Post by mats »

store.sort('foo')
This just sorts the store by a field called foo in your data model, it has nothing to do with the Column.

Post by eguardiola »

Thanks. I now understand that this sort call has nothing to do with the Column. So.. can i click the sort icon of the column programmatically? I need the icon visual pressed status and the sorting to remain between filtering changes. From a user point of view i need not having to press the sort icon to get the sorting the first time the grid is presented to the user. I need to sort one concrete column by default as when i click the sort icon but not having to.

Post by mats »

Try passing in column (which has the field + sortable properties):
grid.store.sort(grid.columns.last)

Post by eguardiola »

Thanks but that has the same effect as grid.store.sort('startDate'). It is sorting but not by using the sorting function passed in the sortable property when configuring the column. Only clicking by hand on the sorter icon of the column is using that sorting function.

Post by eguardiola »

Could be possible to take the sorting widget on the header column and simulate a mouse click event on it?

Post Reply