My query returns all the dates the guest stayed in the hotel (start_date and end_date) .
How can I have the cxGrid select the latest date (selected) in the grid when the query opens ?
By a filter or in code ?
Of all the dates entered I need the latest one.
I am uneasy about selecting sort order of the date field (end_date) to DESC in the cxGrid as sometimes it behaves unpredictable.
Underlying database is absolute database.
This is what I use to get data :
procedure TForm1.ABSTable1AfterScroll(DataSet: TDataSet);
begin
with ABSQuery1 do
begin
Close;
sql.Clear;
if ABSTable1.FieldByName('GUEST_ID').AsString <> '' then
begin
SQL.Text:= 'select * from GUEST_DATA where GUEST_ID = ' +
ABSTable1.FieldByName('GUEST_ID').AsString ;
Open;
end;
end;
end;
You can use the sorting and focusing of the view
procedure TForm1.aDatasetAfterOpen(DataSet: TDataSet);
begin
ViewDate.SortIndex := 0;
ViewDate.SortOrder := soDescending;
View.Controller.FocusedRecordIndex := View.Controller.TopRecordIndex;
end;