Hi,
I have a cxGrid with 3 Levels (MasterView (Level1) and 2 DetailViews (Level2 and Level3) with tabs). Now I want to insert a new record to dataset underlying the second detail view (Level3) and make them visible.
Therefore I must activate/select the second detail view in Level3 but I find no way.
Greetings
Wilfried
Hi Wilfried,
Unless I'm mistaken, the sample from the duplicate report B4249 ("How to programmatically activate the necessary detail View") should help you implement this functionality in your project.
Feel free to contact us if you need any further assistance on this item.
Thanks,
Serge
Hi Serge,
thank you for your response. The sample project was not so helpfully for me because the grid views are changed on the same level.
I have 2 problems:
1)
In my project the focused view is the master view. From there I insert a new record in detail grid 1 (nod grid insert!). To make the new record visible for user I expand the master row and the user can see the new record but the master record is still focused instead the new record in detail view 1. I have tested it with grdDetailView1.Focused:=TRUE and grd.FocusedView:=grdDetailView1 -> no result, the focus stays on the master gridview :-(
2)
Same like 1 but the new record is in detail view2. I can only expand the master grid and then I see only detail view 1 :-(
How can I focus AND select the new record in the detail views?
Greetings Wilfried!
Hi Wilfried,
I'm sorry that the sample wasn't helpful, and I will clarify how the ExpressQuantumGrid works in such situations…
Note that when a GridView is used as a detail View, copies of the GridView object that we call "clones of the View" are created to represent the GridView (for more details on this subject, please refer to the ExpressQuantumGrid's documentation (topic: "Data Representation")). A clone assigns all properties of the GridView, however, it is actually another instance. So, refer to the settings/properties of the clone and its DataController, not its pattern GridView (grdDetailView1).
Here is some sample code for the sample from report B4249 ("How to programmatically activate the necessary detail View"), which illustrates how to focus the 2nd detail GridView of the 1st master row, and then focus its 2nd row. Hopefully, my comments in the code will make it clearer:
procedure TForm1.Button1Click(Sender: TObject); var rowMaster: TcxGridMasterDataRow; begin cxGrid.SetFocus; rowMaster := TcxGridMasterDataRow(viewCustomers.ViewData.Rows[0]); // Take the 1st row - A master row rowMaster.Focused := True; // Focus the master row rowMaster.Expand(False); // Expand the master row rowMaster.ActiveDetailIndex := 1; // Activate the 2nd detail tab of the master row if rowMaster.ActiveDetailGridViewExists then begin rowMaster.ActiveDetailGridView.Focused := True; // Focus the 2nd detail GridView of the master row rowMaster.ActiveDetailGridView.DataController.FocusedRecordIndex := 1; // Focus the 2nd row in the detail GridView end; end;
Please also review the following Knowledge Base article, which may be helpful:
"How to obtain the active View of the Grid"
Article ID: A625 (http://www.devexpress.com/kbA625)
Thanks,
Serge