Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Best Control For Re-Ordering a List

Status
Not open for further replies.

Auguy

Programmer
May 1, 2004
1,206
US
Looking for some advice on which control to use to allow a user to re-order a list. In the past I have used a grid that has a drag and drop feature enabled. Just wondering what others have used for situations like this. I have between 50 and 100 items I will need to re-order. This will need to be done probably no more than once a month.

Auguy
Sylvania/Toledo Ohio
 
I have used the listbox with Moverbars set to .t., an array as controlsource which is populated via select into array and stored back via append from array and merged into the table then.

The data flow is the harder part with that approach, but you don't et moverbars working with an alias rowsource. Nevertheless the UI is working nicely and quite intuitive.

I also used drag&drop in an activex treeview (Exontrol ExGrid which also works quite easy in regard of positioning the rows, it has a setparent method so you can also simply move a subnode by changing it's parent node, so this is even good for reordering data, when it is in the form of multiple levels of hierarchical data (eg 1:n:m relations).

Bye, Olaf.
 
Auguy,

Do you mean you want to let the user drag items up and down the list? If so, the listbox control has a built-in ability to do this. Just set its MoverBars property to .T. The user will then be able to drag items with the mouse, or use various key combos to move them.

Or, do you mean you want to let the user click on a column heading to sort the control into a particular sequence? If so, one way to do that is by adding code to the click event of the header objects. The code would set the index order as appropriate.

Regarding the listbox, although the above solution is easy to achieve, I'm not convinced it's ideal from the user's viewpoint. It might be awkward, given you might have a hundred items for them to juggle around. If you agree, you might have to look for an alternative way of solving the problem.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips, training, consultancy
 
Yes, drag items up and down on a list. I think the listbox will work for my purposes. As I said this isn't going to happen very often and most of the time they will only be moving a few items. Thanks to you and Olaf as usual.

Auguy
Sylvania/Toledo Ohio
 
I've usually used a listbox with Moverbars=.t. just because it's free U/I. Although I usually have to be slapped, shoved, and yelled at to agree to provide this kind of U/I at all. ;-)

Any list that has more than a couple dozen or so entries is unwieldy, IMO. More than one screenfull can be difficult to work with. (It's one of the things I dislike, as a user, about Windows Explorer.)

But the real world intrudes, eh?
 
There are very good cases for using such ordering with a limited amount of items, eg in a recipe, where order of ingredients makes sense and is not making sense to be automatically sorted by amount, alphabetical or by anything else but user defined in the order best for the preparation. And this is not limited to dishes.

And I can imagine many such cases where users like to be in control about the order of the data. I'd only question this, if nowing the use case and if it makes sense or not. You CAN do quite lot of automagically ordering of rows user may not think possible, eg also by ordering in several stages by creating indexes on the fly, even with mixed ascending and descending order (see the other thread about indexing on 2 expressions, but sometimes it makes sense to simply let the user have the control.

Bye, Olaf.
 
Yes, as I said the real world intrudes.

Remember that one problem with the moverbars approach is that it won't work if the list is array-based. You have to load the array elements into the list item by item and later read it back. This can be a performance issue on larger arrays, U/I clumsiness aside.

But if that's what you have to do, then that's what you have to do.
 
I actually have in mind you can both use items added via Additem or Arrays, only not cursors. Without testing, I'd trust you, though, could be I used Additem to propagate the listbox with items.

Bye, Olaf.
 
At least these days we can AddItem() directly to the list.

Back in the FPD/FPM/FPW days, the only way to get moverbars on a list was to base it on a popup. Wanna see software slow down? Try DEFINE POPUP/DEFINE BAR for populating a few hundred items into a list.

It got ugly. Rapidly. Which is the only thing it did rapidly.[sadeyes]
 
Thanks to everyone for their suggestions. I discovered that I really only need to select and re-order 25-35 of the original 50-100 items. Therefore I am going with 2 list boxes, one to contain the 50-100 items and one to contain the selected items that need to be re-ordered. I can use 'mover' buttons to move items between the two list boxes.

Auguy
Sylvania/Toledo Ohio
 
Well, that's also a solution you can both select and order items with, two listboxes with options and selections aka moverbox. If selections are donw in the order wanted, the selections listbox doesn't even need moverbars anymore, but combined this will surely help to both select and order items.

Bye, Olaf.
 
There's even a mover control in the FFC that's already set up for this. Look for "Sort Mover".

 
FWIW
I once created an application in which my users also wanted to have a certain 'priority' which is in fact same as sort.
For that reason I added a 'prority'field to the table
Than by using the listbox with Moverbars = .t. it was quit easy to update that priority-field with the sequence of the items in the listbox.
The number of items was not that that much so I am with others that for large number of items this is not the best solution.
-Bart
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top