Posted 13 November 2023, 4:10 am EST
Hello,
I would like to know if there is any way or method of moving the position line?
for example:
1, 2, 3, 4, 5
if I want to move line 4 between line 1 and 2 to look like:
1, 4, 2, 3, 5
Forums Home / Spread / SpreadJS
Posted by: pedro.moraes on 13 November 2023, 4:10 am EST
Posted 13 November 2023, 4:10 am EST
Hello,
I would like to know if there is any way or method of moving the position line?
for example:
1, 2, 3, 4, 5
if I want to move line 4 between line 1 and 2 to look like:
1, 4, 2, 3, 5
Posted 13 November 2023, 4:44 pm EST
Hi,
I did not completely understand your requirements. In your post, what do you mean by position line? By position line, do you mean ‘grid line’ in SpreadJS Worksheet?
It is important to note that the grid lines are drawn to distinguish between different cells in the sheet.
As per my understanding, your requirement is to move data between columns in SpreadJS. In SpreadJS, you can use the “dragDrop” command to move data from one column to another column. With this command, it can be specified whether the column is to be cut/pasted, copy/pasted, or inserted. This command can be executed with commandManager.execute() method.
For instance, if there are four columns namely A, B, C, and D, and the values in the first cell of these columns are a, b, c and d then the data of column C can be moved to column B. It results in the values a, c, b, and d.
Please refer to the attached sample for more understanding.
If you need further assistance, please let us know. Also, kindly explain your use case/ issue in more detail if the above solution does not fit your requirements.
References:
dragDrop command: https://developer.mescius.com/spreadjs/api/modules/GC.Spread.Sheets.Commands#dragdrop
commandManager.execute(): https://developer.mescius.com/spreadjs/api/classes/GC.Spread.Commands.CommandManager#execute
Regards
Posted 24 November 2023, 7:43 am EST
Thanks,
You are moving column 2 to 1 in the example.
But if I move forward, for example moving column 1 to 2 it doesn’t work.
Posted 27 November 2023, 8:38 pm EST - Updated 27 November 2023, 8:43 pm EST
Hi,
Please note that this behavior is by design. It is this way to keep the similar behavior with the UI.
For instance, if there are four columns A, B, C, and D, and the data of column C is moved to column B with Shift + Mouse drag(UI action) then if the drop line is on the left side of column B, the data of column C is moved to column B. However, if Shift + Mouse drag is started from column B, it needs to be dropped at the right end of column C(start of column D: index 3, meaning index of column A + 2 i.e. 1 + 2 = 3) for the data to be moved.
Please refer to the attached sample and GIF for more understanding.
Regards