This example demonstrates how to use ViewModel properties to track and control focused row changes both for Master and Detail grids. This capability is achieved by creating attached behavior that handles all necessary events (especially for the focused view and row changing, both in the detail and master grids).
So, the main idea of the example is to show how the row focusing logic can be defined in the GridControl that operates in Master-Detail mode.
Important note: the approach shown in the example will work only with the DataControlDetailDescriptor, as other descriptors use custom templates to display detail content that is not synchronized with the master grid.
Please note that this approach is outdated starting with version 15.1, where the capability to bind selection of the master and detail grids was supported out of the box. Starting with that version, bind the CurrentItem/SelectedItem/SelectedItems properties directly as described at Master-detail grid - Add the capability to bind selection and navigation properties.
Question Comments
Added By: Manar Husrieh at: 12/24/2012 4:50:04 AM
Hi,
I have tried to implement the example but I have a problem. When I am using master grid with multiple details using TabViewDetailDescriptor, The parent is not a master grid. I have checked it and its type is TabViewDetailDescriptor and its parent is always null. This problem is in the DetailFocusedRowBehavior in the MasterView property.
Regards,
Manar Husrieh
Unfortunately this example has a serious issue. You can see the problem if you'll do the following:
1) Expand first master row (Bruce). In result we see that in ViewModel FocusedEmployee=Bruce and FocusedOrder=Supplier 1 - TV.
2) Expand second master row (Cindy). In result we see that in ViewModel FocusedEmployee=Cindy and FocusedOrder=Supplier 1 - Blue-Ray Player.
3) Now select Suplier 1 - TV detail row under Bruce master row again. And what we see? In ViewModel FocusedOrder=Supplier 1 - TV, but the FucusedEmployee=Cindy. Obviously I expected to see Bruce selected.
But it's not obvious how to change this example to make it work this way. Can you show how to change this example to automatically focus the parent master row when detail row gets selected?
Hello guys,
I apologize for the delay in our response. Usually, we do not review comments to examples, so, in the future, I suggest you create a support ticket regarding problems you face.
As for your questions:
Manar, I'm afraid it is not possible to use TabViewDetailDescriptor with the demonstrated behavior. It supports DataControlDetailDescriptor only.
Volodymyr, thank you for reporting this issue. This behavior is definitely incorrect. I have fixed it and updated the example.
This example doesn't work for Silverlight. Do you have a similar example for the exact same issue in Silverlight?
Added By: Alexander Ch (DevExpress Support) at: 8/22/2013 11:43:12 PMNo, we don't have such an example for Silverlight. We will consider adding it in the future.
Thanks.
Hi.
there is still a bug in this behavior. Lets examine a situation where FocusedEmployee = TestEmployee and FocusedEmployee contains one Order = TestOrder, and and TestOrder is focused in detail grid. ViewModel will report TestOrder and TestEmployee as focused order / employee respectively. Now try to delete TestOrder. ViewModel will report FocusedOrder = null, FocusedEmployee = TestEmployee, but grid will not show focused row, which is inconsistent with what ViewModel reports. This is because DetailCurrentItemBehavior will set FocusedOrder to null, but there is no code to set focused row to FocusedEmployee, in this case TestEmployee.
Regards,
Goran