Issue with clearSort() function

Tags: #<Tag:0x00007efc651e7e50>

Hi,

We are currently migrating to Handsontable angular wrapper version 11.1.0.

The following was working in previous version (6.0.1):
this.hotRegisterer.getInstance(this.id).getPlugin(‘columnSorting’).clearSort();

But in 11.1.0 it throws the following error stack trace:

ERROR TypeError: Cannot read properties of null (reading ‘getSortStates’)
at ColumnSorting.getSortConfig (columnSorting.mjs:383:1)
at ColumnSorting.sort (columnSorting.mjs:316:1)
at ColumnSorting.clearSort (columnSorting.mjs:354:1)

Please let us know.

Thanks

Hi @a_ntn

Here’s a demo with version 11.1 https://jsfiddle.net/p3xb9rLh/3/
we did not change anything within that method. It is still executed the same way.
Maybe the error is related to the way sorting is attached/done.

Hi Aleksandra,

Actually the expression this.hotRegisterer.getInstance(this.id).getPlugin(‘columnSorting’).clearSort() was working in 6.0.1. But when we moved to 11.1 we see that it crashes. I was trying to find jsfiddle where they have used the expression given above and using 11.1 version.

I request you to please confirm if the following expression this.hotRegisterer.getInstance(this.id).getPlugin(‘columnSorting’).clearSort()
is working for handsontable angular wrapper version 11.1.

Thanks

It seems to work the same in the Angular for Handsontable v11.1. Please see this demo https://jsfiddle.net/eqwokrs0/3/

Could you tell me which Angular version do you use?

Thanks Aleksandra! for confirming the clearSort().
Following is lib versions we use:

@angular/core”: “~11.2.14”
@handsontable/angular”: “^11.1.0”,
“handsontable”: “^11.1.0”

I have updated my demo to that version https://jsfiddle.net/10k3h8s7/1/ and it works the same.
I think that there might be a different change in your code that is blocking the sorting.

Ok Fine, Thanks for making that Demo based on version 11.2. We will check from our side what is missing. But please note that the expression this.hotRegisterer.getInstance(this.id).getPlugin(‘columnSorting’).clearSort()
works for us in lower version ( 6.0). So when migrating to 11.1 we may be missing something.
.

It would be great if you could send us a demo where the issue can be replicable. That way we will be able to tell if that is a change related to the process of migrating to a higher major version or a regression in Handsontable.

Hi Aleksandra,

Yes it seems we could reproduce this issue. In the latest DEMO link you had given to us https://jsfiddle.net/10k3h8s7/1/ please copy-paste the code below for the clearSorting() method

this.hotRegisterer.getInstance(this.id).updateSettings({
columnSorting: false
},false);

this.hotRegisterer.getInstance(this.id).getPlugin(‘columnSorting’).clearSort()

And you will see the runtime error:

?editor_console=true:73 ERROR TypeError: Cannot read properties of null (reading ‘getSortStates’)

but when you make the expression ‘true’ as shown below, then the error vanishes:

this.hotRegisterer.getInstance(this.id).updateSettings({
columnSorting: true
},false);

So as per our observation, in the old version the expression below:

this.hotRegisterer.getInstance(this.id).getPlugin(‘columnSorting’).clearSort()

does not crash and is independent of ‘updateSettings’ columnSorting attribute value.

Thanks

Thank you for sharing the code.

In this example, you are trying to run a method of the columnSorting plugin after you disable the plugin. It does not work that way. A plugin has to be enabled if you want to use its methods.

Yes Thanks!.