PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WEBDEV 2024 → UI Code for record sequencing (moving records up and down in a list)
UI Code for record sequencing (moving records up and down in a list)
Iniciado por Gavin Webb, 08,jul. 2013 08:35 - 2 respuestas
Miembro registrado
6 mensajes
Publicado el 08,julio 2013 - 08:35
Anyone know of any code examples or help as to how best to implement record sequencing i.e. I have a simple reference\lookup table - just a string, but I want my users to be able to order them i.e. not alphabetical order - of course I know I need a sequence field and key - but how best to handle the UI for moving the records up and down......
Publicado el 08,julio 2013 - 14:48
Hi Gavin

this is how I do this:
- the sequencing field is a NUMERIC (not an integer, a HIGH precision
numeric
- when adding a line at the end, the field value gets biggest value+1
- Two buttons in the UI, UP and down
- when pressing Up on line 12 (by example), the sequencing value "S12"
becomes (S11-S10)/2. ie: the new value is set at the "MIDDLE" between
previous and previous-1... This is where the fact that we are using high
precision numeric become invaluable: there is only ONE hmodify to do.
- When pressing DOWN on line 9 (by example, the sequencing value "S9"
becomes (S11-S10)/2 (IF these 2 lines exist), or S10+1 if line 10 is the
last line

Best regards


--
Fabrice Harari
Consultant WinDev, WebDev et WinDev Mobile International

Nouveau site web (EXPERIMENTAL) http://www.fabriceharari.eu
(Plus d'information sur http://fabriceharari.com/index_FR.html)


On 7/8/2013 12:35 AM, Gavin Webb wrote:
Anyone know of any code examples or help as to how best to implement
record sequencing i.e. I have a simple reference\lookup table - just a
string, but I want my users to be able to order them i.e. not
alphabetical order - of course I know I need a sequence field and key -
but how best to handle the UI for moving the records up and down......
Miembro registrado
6 mensajes
Publicado el 08,julio 2013 - 15:09
Thanks, that's exactly what I thought too. Do you have a code example you could share with me to help me get along. I can read current record, I guess then it's a case of read previous record and note value, read previous value again and note value, then calc new value and modify original record and refresh the looper.

Tricky bit I guess is dealing with first and last records and defensive coding around trying to move first record up!