Retrieving itemindex in ListView using drag and drop
Hello
Now I'm creating a form using the "Variable Lookup Listview" to change the
values for Sortorder column in the Components table. The Sortorder
column is used to sort the records in the report.
The form will be responsible for changing the value of Sortorder which is
presented using ORDER BY Sortorder ASC (sortorder is auto number and
unique). I want the moving of the position of the row to cause the value of
Sortorder to change according to the order of the row in the List View by
using "Drag and Drop".
The Button "move up" and "move down" can be used and I would like to thank
Dan Goldberg and Jan: you are my heros.
I want the user to be able to drag a row up or down causing the Sortorder
to change by using UPDATE. I have tried to use many PROPERTYs to retrieve
the RowNo of the target (for example, topitem, itemindex) but I am not
successful.
- Code in the "On start drag"
CLEAR VAR vsorto
SET VAR vsorto INTEGER = sortorder IN test_components WHERE sortorder
=Vsortorder
RETURN
-- code in the "On start drag"
CLEAR VAR vsorto
SET VAR vsorto INTEGER = sortorder IN test_components WHERE sortorder
= .vsortorder
--It is comment testing value a source
{SET VAR vshowitem TEXT = NULL
GETPROPERTY lst_vcom topitem vshowitem
-- GETPROPERTY lst_vcom itemidex vshowitem
PROPERTY btn caption .vshowitem}
RETURN
--code in the "On drag and drop"
-- It is comment testing value the target
{SET VAR vshowi TEXT = null
GETPROPERTY lst_vcom itemindex vshowi
-- GETPROPERTY lst_vcom topitem vshowi
PROPERTY btn_1 caption .vshowi}
CLEAR VAR vrecno
SET VAR vrecno TEXT = NULL
-- I want the GETPROPERTY command to get the Record No. of the Target
record; this doesn’t get it
GETPROPERTY table ‘test_components->RECNO’ vrecno
--Set the Source’s SortOrder = 0
UPDATE test_components SET SortOrder =0 WHERE SortOrder = .vsorto
--Update the records between the source and target records to increase the
value of SortOrder by 1
UPDATE test_components SET SortOrder =SortOrder + 1 WHERE SortOrder >=
.vrecno AND SortOrder =< .vsorto
--Update source record SortOrder (that = 0) to be = target record SortOrder
UPDATE test_components SET SortOrder =.vrecno WHERE SortOrder= 0
PROPERTY lst_vcom refreshlist 'TRUE'
CLEAR VAR vrecno,vsorto
RETURN
Drag and drop does not work at all. A row can be selected and dragged but
after releasing the mouse button the row does not stay in the new location.
It is still in the old location. We ask for help from you to introduce us
to guidelines or other methods that could be better and more elegant. A
sample would be great.
I'm using R: Base for windows 7.6
Thank you very much.
Pramote Padprom, Centre for Vocational Building Technology, Thailand.
2011/12/9 jan johansen <[email protected]>
> Dollar,
>
> As Dan has already suggested, all of things that you want to do can be
> done using the Variable ListView.
> Sometimes when we are starting out we try to use a control that is
> inappropriate for the task at hand.
> A Variable ListView has the ability to drag and drop, select multiple rows
> and sort by individual columns
>
> Additionally the following PROPERTY's are beneficial in accomplishing your
> task.
>
> MULTISELECT
> TOPITEM
> CURRENTSORT
> MAKECLICK and ITEMINDEX (useful for items moving up and down the list.
>
> Good luck,
>
> Jan
>
>