Description:
How can I reorder records or move them to another view using drag-and-drop?
Answer:
You need to manually modify the grid's data at the dataset or DataController level to accomplish this task. Handle the OnDragDrop, OnDragOver, and OnStartDrag to respond to drag-and-drop operations. Hit tests will help you determine the record under the mouse cursor.
The attached project illustrates a possible implementation of drag-and-drop.
See also:
How to obtain the Grid row at a given location on the screen
How to drag a cell's value to an external editor
Why does my custom DragObject not function?
How to allow an end-user to perform a drag and drop operation with a specific criteria
This example has a problem. Watch my sample video for clarification. I attached the source code too.
Hello,
The "order" field must be of type TFloatField. This modification should help.
Code is very useful to me, thank you!
Prerequisite:
Set <View>.DataController.KeyFieldNames to the key-field(s) of your Dataset.
Otherwise, the "ADC.LocateByKey(AKeys)" won't do its job…
Is it possible to add a sample for C++?
And the user is only allowed to drag&drop a record which has specific data. So I need to check the record value.
Thanks
Thomas
Hello Thomas,
I've created a separate ticket on your behalf (T414461: Add a C++ project to A461 KB article). It has been placed in our processing queue and will be answered shortly.
C++ sample.