tClientDataSet如何排序?似乎没有类似TAdoDataSet.sort的属性

telstar 2005-01-21 05:28:41
如题
...全文
255 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
bbm011 2005-01-21
  • 打赏
  • 举报
回复
是没有这属性
bbm011 2005-01-21
  • 打赏
  • 举报
回复
把下列過程加如dbgrid的OnTitleClicks事件裏。

var
FieldName, DecFld, upMark, dnMark: string;
i: Integer;
begin
if SortData.IsEmpty then System.exit;
upMark := '▼';
dnMark := '▲';

if pos('*',PFieldname)>0 then
PFieldname:=copy(PFieldname,1,pos('*',PFieldname)-1);
for i := 0 to SortData.FieldCount - 1 do
begin
if pos(upMark, SortData.Fields[i].DisplayLabel) > 0 then
SortData.Fields[i].DisplayLabel := copy(SortData.Fields[i].DisplayLabel,
1, pos(upMark, SortData.Fields[i].DisplayLabel) - 1);
if pos(dnMark, SortData.Fields[i].DisplayLabel) > 0 then
SortData.Fields[i].DisplayLabel := copy(SortData.Fields[i].DisplayLabel,
1, pos(dnMark, SortData.Fields[i].DisplayLabel) - 1);
if SortData.Fields[i].FieldName = PFieldname then
begin
if (SortData.Fields[i].FieldKind = fkData) and (SortData.Fields[i].DataType
<> ftBlob)
and (SortData.Fields[i].DataType <> ftMemo) and
(SortData.Fields[i].DataType <> ftGraphic) then
begin
if IsAec then
SortData.Fields[i].DisplayLabel := SortData.Fields[i].DisplayLabel +
upMark
else
SortData.Fields[i].DisplayLabel := SortData.Fields[i].DisplayLabel +
dnMark;
end
else
System.exit;
end
else
begin

continue;
end;
end;

SortData.IndexDefs.Clear;
SortData.IndexDefs.Update;
if IsAec then
DecFld := PFieldname;

IsAec := not IsAec;
FieldName := PFieldname;
if FieldName <> '' then
begin
with SortData.IndexDefs.AddIndexDef do
begin
IndexFld := IndexFld + 1;
Name := IntToStr(IndexFld);

Fields := FieldName;

DescFields := DecFld;
end;

SortData.IndexName := IntToStr(IndexFld);
end;
ttjacky 2005-01-21
  • 打赏
  • 举报
回复
好像用那个IndexFieldName就可以了,楼上的也没问题
aiirii 2005-01-21
  • 打赏
  • 举报
回复
可以的, 檢查你的代碼
telstar 2005-01-21
  • 打赏
  • 举报
回复
不是吧,不行呢
aiirii 2005-01-21
  • 打赏
  • 举报
回复
oh, 最後還要加一句:

cds.IndexName := lIndexName;
aiirii 2005-01-21
  • 打赏
  • 举报
回复
cds.AddIndex(lIndexName, ColumnFieldName, [ixDescending]);

查查 AddIndex 的用法就可

2,495

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 数据库相关
社区管理员
  • 数据库相关社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧