I have a table containing a few fields. The table is sorted by one of these fields, say "date".
I have connected a TDBAdvGrid to this dataset and set PageMode=false. I have also connected to the field "date" to a DBEdit.
If I change the value of "date" via DBEdit and then do a table.requery the table is re-sorted correctly this is not reflected in TDBAdvGrid and I assume it is because PageMode=false.
How can I solve this ?
You can call
This works, thank you.
I also have Pagemode=false and I want to do some similar stuff.
I have a AdoQuery Component on the form. This is Connected to a Datasource and then to the DBAdvGrid. The underlying Query is Select * from table where (som statement). So the Fields are show automaticaly as I don't know alle the fieldnames in advance.
When I change my SQL (i.e. making a character upercase or lowercase) and then do reload, my grid gets emptied and I can only see one grey cell in the left upper corner.
This is the code behind my button:
procedure TForm.ButtonClick(Sender: TObject);
//Not important what you do. Add a Space or ";" at the end will also produce the same result.
ADOQuery1.SQL.Text := 'select * from table';
Data in the Grid is not shown. Only an empty cell in the top left corner :-(
I use the latest Version of the Control = 184.108.40.206
Ole Henrik Oftedal
Timeflex Systemer AS
I don't see in your code that you set the dataset active again. That is of course necessary and doing this, it should not be necessary to call Reload.
Hi. Thanks for quick reply. I had already tried that. But now I think I've found out why I had a problem.
If the user (or me) hides a column and after that changing the underlying dataset, the grid will remove all columns or in some case will display only one column. The columns are beeing destroyed by the grid in this scenario.
// My workaround when you must refresh the grid and you have one or more columns hidden.
//Save all that you can
s := DBAdvGrid1.ColumnStatesToString;
s2 := DBAdvGrid1.SortSettings.SaveToString;
//Get back all the colums
//Stop the filer
DBAdvGrid1.FilterActive := false;
ADOQuery1.Active := false;
//Change the underlying query
ADOQuery1.SQL.Text := 'select * from Table'
ADOQuery1.Active := true;
DBAdvGrid1.FilterActive := true;
// If you hava a SUM line or a Columncalc in the footer then reaply them here.
// They are lost in the process.
//Restore columns and sort settings