Page 1 of 1

Grid programmatic row reordering

PostPosted: Thu May 11, 2023 10:21 am
by neil.interactit
Hi Mike,

I have made good use of your Sample Plugin Editable List Maintenance as a ShowDialog(), thanks!

The client has come back with a specific requirement to be able to re-order a group of rows.

Something like grdLines.AllowMultipleRowSelect = true, and then letting the underlying FarPoint grid do the heavy lifting would be an easy option, but I couldn't spot or locate this functionality?

Alternatively, I have access to everything else I need (grdLines.RowDragMoveCompleted, etc) to be able to programmatically "override" the single row move and move the remaining rows in the group if I could access something like grdLines.RowMove(fromIndex, toIndex, count).

Could you advise if I'm barking up the wrong tree, of if there is an approach available?

Cheers,
Neil.

Re: Grid programmatic row reordering  Topic is solved

PostPosted: Thu May 11, 2023 10:53 am
by Mike.Sheen
neil.interactit wrote:The client has come back with a specific requirement to be able to re-order a group of rows.

Something like grdLines.AllowMultipleRowSelect = true, and then letting the underlying FarPoint grid do the heavy lifting would be an easy option, but I couldn't spot or locate this functionality?


I believe the AllowMultipleRowSelect property would only be useful for allowing the user to select multiple rows, no necessary if you want to move them using code.

neil.interactit wrote:Alternatively, I have access to everything else I need (grdLines.RowDragMoveCompleted, etc) to be able to programmatically "override" the single row move and move the remaining rows in the group if I could access something like grdLines.RowMove(fromIndex, toIndex, count).

Could you advise if I'm barking up the wrong tree, of if there is an approach available?


Now I'm confused - the drag events occur after the user has moved rows on the grid with the mouse - if you're wanting to programmatically move rows, then those events are of no use to you - use the MoveRow method to use your code to move rows - e.g.: to move row 0 to row 5:
Code: Select all
grdLines.ActiveSheet[0].MoveRow(0, 5, true);


You could also use a custom sort if that's more appropriate - depends on what you're trying do - but MoveRow will certainly move rows.

Re: Grid programmatic row reordering

PostPosted: Thu May 11, 2023 2:00 pm
by neil.interactit
Probably more accurately - I was confusing!

THat was the method I couldn't spot - thanks - I can make that work.

The basic plan is to allow the user to drag a single row, capture RowDragMoveCompleted, prevent recursion, then .MoveRow() the other rows in the group.

So, given rows A1,A2,B1,B2,C1,C2,C3,D1,D2 if C1 is dragged to B1 then .MoveRow() can also move C2,C3 then finally allow the ItemNo renumbering to fire.

I'll give it a go.

Cheers,
Neil