Add a function that resets manualColumnMove order

Tags: #<Tag:0x00007f8b290c21d0>

I have my app connected to firebase to handle realtime updates to allow multiple users to work on the same sheet. This includes changing the order of any column. I am keeping a map between the logical indices and the column ID in firebase. But when the order changes in firebase, I move the respective columns for other users on the same sheet using the “ManualColumnMove” plugin like so:
hot.getPlugin('ManualColumnMove').moveColumn(change.oldIndex, change.newIndex+1);
However, that causes the physical index to not match the logical ones.
How can I reset the physical indices to match the logical ones?

Hi @aabounegm

I am not sure if I fully understand your request.

If you move the columns from the original state the physical and visual incides always differ. And if you want to reset the difference you need to reset the order like here http://jsfiddle.net/handsoncode/6kc12keg/ (where I disabled the plugin).

Please let me know if there’s anything that I am missing.

That is not what I meant. I want manualColumnMove to be true (to allow users to move columns as they wish), I only want to programmatically reset the physical indices to match the logical ones.
This is because I have an array that maps between columns in Handsontable and their respective locations in Firebase Database, based on the logical index.
I made a workaround in my Map to base it on the physical index, but I am still testing it

Hi @johnothetree

I have just spotted that even if we disable the plugin to get the correct column order and enable it again - we get the same order. Also, there is no function that resets the order. I allowed myself to change the title.

If what you mean is resetting the order visually by returning columns to what they were before moving them, then this is not what I meant. I simply meant to keep the visual order as it is, and simply not depend on the physical index. But since hooks like afterChange use the physical index, I can’t simply ignore it. I could change everywhere that uses the index to use hot.toVisualColumn(col), but I thought it would be easier if there were a way to just reset the indices programmatically to match again (without changing what the user sees).
I already did a workaround (using hot.toPhysicalCol(col) in just one place), so for my case I’m good for now.