miércoles, 5 de mayo de 2010

Ordenar DataWindow por cabecera

Este script, ordena un DataWindow dandole clic en la cabecera, lo uso en mis DataWindows de tipo Grid, espero sea de gran utilidad:

String ls_CurObj, ls_CurCol

Integer li_LinePos

ls_CurObj = String(dwo.Name)
li_LinePos = Integer(This.Describe(ls_CurObj + ".X"))+ (Integer(This.Describe(ls_CurObj + ".Width")) - 20)

IF Row = 0 AND This.Describe(ls_CurObj + ".Text") <> "!" AND This.Describe(ls_CurObj + ".Band") = "header" THEN // Valid header object?
ls_CurCol = Left(ls_CurObj, Len(ls_CurObj) - 2)
IF is_OrderCol <> ls_CurCol THEN
is_OrderCol = Left(ls_CurObj,Len(ls_CurObj) - 2)

is_SortType = "A"

This.SetSort(is_OrderCol + " " + is_SortType)
This.Sort()
ELSE
IF is_SortType = "A" THEN
li_LinePos -= 20
of_sortdesc(li_LinePos)
is_SortType = "D"
ELSE

is_SortType = "A"

END IF
This.SetSort(is_OrderCol + " " + is_SortType)
This.Sort()
END IF
END IF

Nota: Este script lo pueden colocar en el Evento Clicked o crear un UserEvent y invocarlo desde el evento Clicked, es ya decisión del desarrollador.

No hay comentarios: