22-04-2020, 12:33 PM
التعليمة DESC تعمل في Query وليس في Table عليك بمراجعة الرابط التالي
http://docwiki.embarcadero.com/Libraries...FieldNames
جرب الكود التالي
http://docwiki.embarcadero.com/Libraries...FieldNames
جرب الكود التالي
كود :
procedure SortingTable(DataSet: TFDDataSet; AColumn: TColumn);
var
FieldName, Sort: string;
SortPos: Integer;
procedure SwapSort;
begin
if Sort = '' then
Sort := ':AN'
else
begin
if Sort[2] = 'D' then
Sort[2] := 'A'
else Sort[2] := 'D';
end;
end;
begin
if AColumn.Field.IsBlob then
Exit;
SortPos := Pos(':', DataSet.IndexFieldNames);
if SortPos = 0 then
SortPos := Length(DataSet.IndexFieldNames) + 1
else Sort := Copy(DataSet.IndexFieldNames, SortPos, 3);
FieldName := Copy(DataSet.IndexFieldNames, 1, SortPos - 1);
if FieldName = AColumn.Field.FieldName then
SwapSort
else
begin
Sort := ':AN';
FieldName := AColumn.Field.FieldName;
end;
DataSet.IndexFieldNames := FieldName + Sort;
end;
