想实现当点击数据窗口的标题时
数据窗口中的数据按照,所点击的标题的条件进行排序
如下:
no name sex
1 a g
2 c b
3 b b
点击no,记录的顺序首尾倒置(逆序),再点击一次变成原来的顺序(正序)
其他的列也是同样,数据记录是通过很多的限制条件查询得到的
这样的功能很普通,大家都见过
新手,还请大家赐教,最好写的详细点
...全文
3411打赏收藏
高手请帮忙呀,数据窗口的排序问题
想实现当点击数据窗口的标题时 数据窗口中的数据按照,所点击的标题的条件进行排序 如下: no name sex 1 a g 2 c b 3 b b 点击no,记录的顺序首尾倒置(逆序),再点击一次变成原来的顺序(正序) 其他的列也是同样,数据记录是通过很多的限制条件查询得到的 这样的功能很普通,大家都见过 新手,还请大家赐教,最好写的详细点
if dwo.Type = 'text' then
Text = dwo.Name
Column = Left(Text, Len(Text) - 2)
if is_sort = " A" then
is_sort = " D"
else
is_sort = " A"
end if
this.SetSort(Column + is_sort)
this.Sort()
end if
if dwo.Type = 'text' then
if Text = dwo.Name then
Column = Left(Text, Len(Text) - 2)
if is_sort = " A" then
is_sort = " D"
else
is_sort = " A"
end if
else
Text = dwo.Name
Column = Left(Text, Len(Text) - 2)
is_sort = " A"
end if
this.SetSort(Column + is_sort)
this.Sort()
end if
这样,可以避免连续的两次针对不同列的点击造成的排序没有按照我们的意思执行的状态。
if dwo.Type = 'text' then
Text = dwo.Name
Column = Left(Text, Len(Text) - 2)
if is_sort = " A" then
is_sort = " D"
else
is_sort = " A"
end if
this.SetSort(Column + is_sort)
this.Sort()
end if
白兔兄的最明了,最好了。
str_objectname=string(dwo.name) //对象名称
if row=0 and this.describe(str_objectname+".band")="header" and this.describe(str_objectname+".text")<>"!" then //是否点击列对象
str_curcol=left(str_objectname,len(str_objectname) - 2) //当前列对象名称
if str_curcol<>i_str_oldcol then //点击的是不同列对象
this.modify("destroy p_sort") //不管有没有位图对象都删除
i_str_oldcol=str_curcol //保存上次点击的列对象
//画图
int_pic_x=integer(this.describe(str_objectname+".x"))+(integer(this.describe(str_objectname+".width")) - 70)
str_addpic='create bitmap(band=foreground filename="up.bmp" x="'+string(int_pic_x)+'" y="24" height="33" width="51" border="0" name=p_sort visible="1")'
this.modify(str_addpic) //动态画个图
this.setsort(str_curcol +" A") //头一次点击当然是升序了
this.sort()
else //当前列已经点过了
if this.describe("p_sort.filename")="up.bmp" then //上次是升序
this.modify("p_sort.filename='down.bmp'")
this.setsort(str_curcol+" D") //这次是降序
else
this.modify("p_sort.filename='up.bmp'")
this.setsort(str_curcol+" A")
end if
this.sort()
end if
end if
ls_CurObj = String(dwo.Name)
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 // Different Column
is_OrderCol = Left(ls_CurObj,Len(ls_CurObj) - 2)
is_SortType = "A" // Ascending sort
This.SetSort(is_OrderCol + " " + is_SortType)
This.Sort()
Else
If is_SortType = "A" Then
is_SortType = "D"
Else
is_SortType = "A"
End If
This.SetSort(is_OrderCol + " " + is_SortType)
This.Sort()
End If
End If