IndexName (Delphi)
Description
This example uses the IndexName property to sort the records in a client dataset on the Field2 field.
Code
procedure TForm1.Button3Click(Sender: TObject);
var
I : Integer;
begin
// If Active is True, Update will remove Fields added in FormCreate
// and add the DEFAULT_ORDER and CHANGEINDEX Fields.
CDS2.Active := False;
{ Get the current available indices. }
CDS2.IndexDefs.Update;
{ Find a field named 'Field2'. }
for I := 0 to CDS2.IndexDefs.Count - 1 do
if CDS2.IndexDefs.Items[I].Fields = 'Field2' then
begin
{ Set that index as the current index for the dataset.}
CDS2.IndexName := CDS2.IndexDefs.Items[I].Name;
end;
CDS2.Active := True;
end;
Uses
- Datasnap.DBClient.TCustomClientDataSet.IndexDefs ( fr | de | ja )
- Datasnap.DBClient.TCustomClientDataSet.IndexName ( fr | de | ja )
- Data.DB.TIndexDefs.Update ( fr | de | ja )
- System.Classes.TCollection.Count ( fr | de | ja )
- Data.DB.TIndexDefs.Items ( fr | de | ja )
- Data.DB.TIndexDef.Fields ( fr | de | ja )
- Data.DB.TNamedItem.Name ( fr | de | ja )