Can i change in the row with drag and drop?
Can i change in the row with drag and drop?
Hi,
I made a little example for you and this should be enough for you to get going :
Task screen
Start off by making a Task that has 2+PK amount of parameters. We need the PK columns as Parameters, one from_order_no and one to_order_no as we need to know where the user drags to. The parameters can be hidden.
Next up, connect the task to the desired table at Table tasks. We only need to connect one Task parameter at Table task parameters as the Drag and drop will fill the other parameters.
Subject screen
At Subjects, search up the desired table and navigate to the tab Links > Drag-drop. Create an entry here by having the source tab and target tab equal, selecting your drag-drop task and choosing the Move effect. On the Drag-drop parameters tab, make sure your PK parameters and the from_order_no is Passed as value. Then on the Drag-drop interaction tab, make sure it is allowed to Drag-drop on the desired table and/or variant. Sometimes we would like to be able to drag-drop in certain screens but not in others.
In Subject > Settings, you may choose to check the box Def. drag-drop enabled. Like the name implies, the user can drag-drop immediatly when entering the screen. Leaving this off will result in the user having to enable this in the List of the subject.
Functionality screen
The Task of course needs some coding. Make an entry in Functionality for the task. Make a Template (or generate one by assigning the template first to the Task) and use the following code:
/* Continue if different */
if @from_order_no <> @to_order_no
begin
/* Copy all records into #temp */
select *
into #temp
from table] t
/* Make space for reorder */
update t
set t.order_no = order_no * 10
from #temp t
/* Alter order no of dragged row (+1/-1 depending higher/lower dragging) */
update t
set t.order_no = @to_order_no * 10 + iif(@to_order_no < @from_order_no, -1, 1)
from #temp t
where t.id = @id /* PK columns */
/* Reorder all items */
;with reorder_order_no as (
select t.id /* PK columns */
,row_number() over (order by t.order_no asc) as new_order_no
from #temp t
)
update t
set t.order_no = new_o.new_order_no
from table] t
join reorder_order_no new_o
on new_o.id = t.id /* PK columns */
end
Note that this script includes ntable], this is a parameter that can be automatically filled upon generating with a value you can set in Functionality > Assigning > Assigned templates > Parameters. Create an entry if not already there giving in the following values:
This leaves you with Generating and deploying the code onto the database in Result.
Now drag and drop should function in your application!
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.