PDA

View Full Version : custon ordering


Keltoi
10-25-2002, 02:48 PM
Is it possible to create an interface where a user can sort information in
any way they choose.

For example the list:
Aberdeen
Bristol
London

could be customised to:
Bristol
London
Aberdeen

Obviously I know that by changing unique numbers in the db table will enable the information to be sorted. But how to build an interface that will enable a user to visibly place Bristol at the top of the list, and for all the rest of the values to be reduced in order?

I hope that make sense.

Any help much appreciated,

Keltoi

allida77
10-25-2002, 09:25 PM
When I do this I usually have a sequence field in my db for each field. With javascript allow a user to move a field up or down in a select box with the value being the ID of the dbfield. Pass the array of your IDs to your process page. When you are updating your db do something like

listnum = 1

dim strCheck
For each strCheck in Request.Form("lstCtgy")
rsSrtType.MoveFirst
rsSrtType.Find "TASK_TYPE_ID_NBR = '" & CStr(strCheck) & "'"
rsSrtType("TASK_SORT_SEQ_NBR") = listnum
rsSrtType.Update
listnum = listnum + 1
Next

When you update your are finding the first ID in the array putting listnum in the Sequence field. Listnum is then incremented by 1 and the next ID is found and so on.

Does that help?

Keltoi
10-26-2002, 10:29 AM
yes that does help thanks, though I'm unsure how to piece it all together.

I hate to ask as I usually learn a lot more by trial and error, but do you have a working example of the code?

I know it's a lot to ask, but I think in this case I'd learn more by example.

Many thanks for your time.

Keltoi

Keltoi
10-26-2002, 12:08 PM
I've just been pointed to a rough'n'ready demo for sorting like this.

Seems to work a treat

http://www.charon.co.uk/downloads/tablesort.zip