TcxCustomGridTableItem.SortOrder Property
Specifies the sort order of the data item.
Declaration
property SortOrder: TcxGridSortOrder read; write;
Property Value
Type | Description |
---|---|
TcxGridSortOrder | The active sort order. |
Remarks
Use SortOrder
and SortIndex properties to sort data in the parent grid View against the current data item. Set the SortOrder
property to soAscending or soDescending to sort data in ascending or descending order against the data item.
Tip
You can call the parent grid View’s DataController.ClearSorting procedure to clear the current sort order.
Code Example
The following code example creates a data-aware column, associates it with a field in the dataset bound to the parent grid Table View, sorts data against the created column in descending order, sets a single-line text editor as the column’s in-place editor, and customizes editor settings:
uses cxTextEdit;
// ...
var
AColumn: TcxGridDBColumn;
ATextEditProperties: TcxTextEditProperties;
begin
AColumn := cxGrid1DBTableView1.CreateColumn; // Creates a new data-aware column
AColumn.DataBinding.FieldName := 'ContactName'; // Binds the created column to the "ContactName" field
cxGrid1DBTableView1.DataController.ClearSorting(False); // Clears the current sorting
AColumn.SortOrder := soDescending; // Sorts data against the created column in descending order
AColumn.PropertiesClass := TcxTextEditProperties; // Assigns an in-place single-line text editor
ATextEditProperties := AColumn.Properties as TcxTextEditProperties;
ATextEditProperties.BeginUpdate; // Initiates the following batch change
try
ATextEditProperties.Nullstring := 'Add a contact name'; // Prompts users to enter a contact name
ATextEditProperties.UseNullString := True; // Displays the defined text hint in an empty editor
ATextEditProperties.MaxLength := 30; // Limits the maximum contact name length
ATextEditProperties.Alignment.Horz := taCenter; // Centers column content
finally
ATextEditProperties.EndUpdate; // Calls EndUpdate regardless of the batch operation's success
end;
end;
Default Value
The SortOrder
property’s default value is soNone.
The default SortOrder
property value indicates that the parent grid View does not sort data against the current data item.