DASH AG GRID - How to get rows order if the rows are dragged?

Hello guys,

I would like to create a callback where I can get the rows order of the table;

The idea is to allow the user to reorder the rows by dragging and dropping it, and then, providing the user the option to save the new order of the rows;

The idea is to get the new list always it is changed as the GIF below:
CPT2409181432-697x414

If you want an MRE to work on this, you can use the one below I created a few months ago:

Any help is very welcome!

Hello @kabure,

In order to get the data in the revised order, you can use virtualRowData

3 Likes

Thank you man! I think it’s what I was looking for!

But one other question, do you know how could I sort the rows ?

Let’s say that the default order is [“a”, “b”, “c”]

If the user change the order to [ “c”, “a”, “b”] and save it, there’s a way I could reset this order in an “easy” way?

What do you mean exactly by reset?

As I intend to save the state the user saved, I would like to load the list that the user saved with the new order of the rows and sort the table based on these values

I’m sure I can do this with Pandas, but I would like to know if there is a more direct way to do this row reordering

You should be able to save the columnState, this will include the sorting. Whereas the filterModel will save any filters that they had going.

1 Like

ColumnState also save the rows sorting info??

columnState saves the state of the column, this will have sort as a key value in each column.

hummm I see… But what I need to do is on the rows =/

Anyway, thank you very much, man! I think that I can it directly on pandas without problem

What order the columns are in too is saved in the columnState, so if a user drags a column in front of another it would save.

Hi @kabure !
Take a look at this example, I think that can help:

It has preset sorts and can also save the current sort to re-apply it later.

You can also take a look at

To see what’s inside the column state