sortingEnabled not available on gridInstance

Tags: #<Tag:0x00007efc625648d8>

Hi, I have handsontable in an angular 6 application, and notice that some options don’t seem to be available via the wrapper

For example, in Angular JS you can call gridInstance.sortingEnabled and gridInstance.sortColumn to resolve the physical index for a row in a of a sorted grid

Is there some way to do this in Angular 6?

I’m having the same problem as outlined and resolved in this issue for AngularJS: https://github.com/handsontable/handsontable/issues/2417

Thanks

Hi @escape1979uk

Here is an example on how to get the columnSorting methods exposed via external function in Angular https://stackblitz.com/edit/angular-dnzpev?file=src/app/app.component.ts

Let me know if it works for you.

Sadly it doesn’t help, as it doesn’t appear to expose the information that I need.

Basically I need to know if the grid is Sorted and, then get the row data by index

The AngularJS calls we use are:

To Ascertain sorting status -
grid,sortingEnabled
grid.sortColumn

To get the row data from a sorted grid (if the conditions above are true)
grid.sortIndex[idx][0];

Can you please let me know how these are exposed via the Angular wrapper?
An example detailing the Angular version of the solution posted in the link would be very useful!

Thanks again,
Matt

Update demo https://stackblitz.com/edit/angular-xwxg6x?file=src/app/app.component.ts

Here I am logging the sorting order and the column index.

Can you tell me more about this requirement:

then get the row data by index

Do you need any specific row or just all the data after it gets sorted?

Hi Aleksandra,

I just need to reliably get the row data when the grid is sorted.
In AngularJs, we use the solution in the post from my original question, but there isn’t an obvious way to implement this with the Angular wrapper

On clicking a Row, I need to get the data of the row whether the grid is sorted or now

Let me know if you need any more info
Thanks,
Matt

Can you check this example https://stackblitz.com/edit/angular-abrwvq?file=src/app/app.component.ts ?

I am logging the result

Sorry I was in a rush and didn’t explain myself correctly…

I’ve updated the stackblitz to demonstrate the issue I am facing,

On the amend of a cell, I need to capture the row source data because we have multiple dependent values to resolve based on the value set.

When the grid is sorted, the change event does not give the physical row index of the data.

To reproduce, leave the grid unsorted and change the value of a cell
In the console, you will see that the source data for the row is output correctly,

Now sort the grid, and change a cell. You will see that the value output in the log is NOT the expected source data.

I need a way to get the source row data on a change event even when the grid is sorted

When the grid is sorted, the change event does not give the physical row index of the data.

I think that you are looking for the toPhysicalRow method https://handsontable.com/docs/6.1.1/Core.html#toPhysicalRow it works on the physical indexes while sorting works on visual indexes.

That works perfectly, thanks!

1 Like

Happy to help :slight_smile: