Sorting with API only

I need sorting only through the API since the headers on our table are customized and interactive. Given that the sort functionality wraps all the content on each header my custom events are lost. How do I enable sorting only through the API and leave the headers intact?

Although I would like to know if there is a method to fully disable the headers from sorting without having to add custom code I found an example of how to add listeners for elements on the headers:

http://docs.handsontable.com/0.26.1/demo-custom-renderers.html#page-header

Hi,

Currently the columnSorting plugin does support any easily-managed functions to get the described effect.

Here’s a set of methods for the columnSorting plugin: https://docs.handsontable.com/pro/1.5.1/ColumnSorting.html#setSortingColumn

Thanks for the reply, could you provide a fiddle with setSortingColumn in action with columnSorting = false?

I have tried to dynamically enable the plugin but I have not been able to other than having columnSorting = true which then forces the headers to be clickable which we are trying to avoid.

I noticed a similar response in github: https://github.com/handsontable/handsontable/issues/3270

“Currently it’s not available, but you can forcefully set sorting order with setSortingColumn(col, order).”

I would like to know how we can forcefully set the sorting order which would solve our issues.

Hi @anne.vela

columnSorting has to be enable to let it’s methods work.
Here’s an example http://jsfiddle.net/85uz6pk6/

Hi @aleksandra_budnik,

Thanks for confirming that columnSorting must be enabled in order for the plugin to work which takes us back to the original issue that header content gets wrapped with the sorting functionality. We have developed a work around for this “issue” but is there a way to add this feature as part of your backlog?

Thanks,
Helmut

Hi @helmutgranda
I would love to see your workaround (if that’s OK). I would surely help us to add this feature in the future.

Hi @aleksandra_budnik,

Our solution is rudimentary:

  • Capture the click event at the element inside the header
  • If you click on the header we prevent from sorting to happen
  • Remove hand indicator on hover

Sorting is still available through the API, however by looking at the source there is a more elegant solution that could be applied in the Sort method in the core library but we don’t have time to do such implementation at the moment.

Let us know if you are able to integrate an elegant solution to the library, if we have time to enhance the source we will be more than happy to contribute.