-1

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;
moskito-x
  • 11,832
  • 5
  • 47
  • 60
user763539
  • 3,509
  • 6
  • 44
  • 103
  • "I am uneasy about selecting sort order of the date field (end_date) to DESC in the cxGrid as sometimes it behaves unpredictable". How does it behave unpredictably? I have heavily used DevExpress grids for over 10 years and have never seen unpredictability in their sorting behavior. – Sam M Apr 04 '13 at 15:42
  • Sometimes it just quits sorting ... Why? I do not know... Witnessed it twice in my short career .... – user763539 Apr 04 '13 at 17:59

1 Answers1

2

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;
bummi
  • 27,123
  • 14
  • 62
  • 101