We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Selected items in master - detail datagrid

Hi,
 
I am trying to make a master - details datagrid, in which I monitor the selected rows in the details grid. By the way, I'm using SfDataGrid elements.
 
I can successfully track current selection in the master grid, by using the event
 

SfDataGrid.SelectionChanged

 
in the event handler, I check the content of the properties
 
 

SfDataGrid.SelectedItems

 

SfDataGrid.SelectionController.SelectedRows

 
 
Now, I tried to do the same with the details grid. I subscribed to SelectionChanged event. The event is fired, but the two properties listed above, always have empty content.
 
In SyncFusion online documentation, I found this information:
 
There are some limitations in Master-Details View.
...
- It does not have support to bind SelectedItem, CurrentItem.
...
 
Here it says that it is not possible to do a binding; but is it possible to deal with selected items in some way, also programmatically (in C# code)?
 
Thanks,
Emanuele
 

5 Replies

FP Farjana Parveen Ayubb Syncfusion Team January 29, 2015 07:37 AM UTC

Hi Emanuele,

Thank you for contacting Syncfusion support.

We have analyzed your query. Please refer the following updates.

Query

Response

Getting SelectedItem in master details view by using SelectionChanged event.

You can achieve your requirement by using SelectionChanged event of details grid.

Please refer the code snippet and sample in the following location:

Code Snippet:

void FirstDetailsViewGrid_SelectionChanged(object sender, Syncfusion.UI.Xaml.Grid.GridSelectionChangedEventArgs e)

{

    var grid = (e.OriginalSender as DetailsViewDataGrid);

    var selectedrows = grid.SelectionController.SelectedRows;

    var selecteditems = grid.SelectedItems;

}

There are some limitations in Master-Details View.

...

- It does not have support to bind SelectedItem, CurrentItem.

...

 

Here it says that it is not possible to do a binding; but is it possible to deal with selected items in some way, also programmatically (in C# code)?

 

In details view grid you can’t able to bind the SelectedItem and CurrentItem. But, you can achieve this by using Behaviour and Dependency Property.

Please refer the code snippet and sample in the following location:

Code Snippet:

<local:SelectionBehaviour FirstDetailsViewSelectedItem="{Binding SelectedFirstNestedGridOrderDetails, Mode=TwoWay}"

                            FirstNestedSelectedItems="{Binding FirstNestedGridSelectedItems , Mode=TwoWay}"

                            FirstNestedCurrentItem="{Binding FirstNestedCurrentDetails,Mode=TwoWay}"/>

Sample Location: SfDataGrid_MasterDetailsView.zip

Regards,

Farjana Parveen A






EP Emanuele Panzavolta January 29, 2015 06:44 PM UTC

Hi, many thanks for your help!
 
Regards,
Emanuele


FP Farjana Parveen Ayubb Syncfusion Team January 30, 2015 05:06 AM UTC

Hi Emanuele,
 
Thank you for your update. Please let us know if you require further assistance on this.
 
Regards,
Farjana Parveen A




NA Nacho replied to Farjana Parveen Ayubb December 17, 2020 03:34 AM UTC

Hi Emanuele,

Thank you for contacting Syncfusion support.

We have analyzed your query. Please refer the following updates.

Query

Response

Getting SelectedItem in master details view by using SelectionChanged event.

You can achieve your requirement by using SelectionChanged event of details grid.

Please refer the code snippet and sample in the following location:

Code Snippet:

void FirstDetailsViewGrid_SelectionChanged(object sender, Syncfusion.UI.Xaml.Grid.GridSelectionChangedEventArgs e)

{

    var grid = (e.OriginalSender as DetailsViewDataGrid);

    var selectedrows = grid.SelectionController.SelectedRows;

    var selecteditems = grid.SelectedItems;

}

There are some limitations in Master-Details View.

...

- It does not have support to bind SelectedItem, CurrentItem.

...

 

Here it says that it is not possible to do a binding; but is it possible to deal with selected items in some way, also programmatically (in C# code)?

 

In details view grid you can’t able to bind the SelectedItem and CurrentItem. But, you can achieve this by using Behaviour and Dependency Property.

Please refer the code snippet and sample in the following location:

Code Snippet:

<local:SelectionBehaviour FirstDetailsViewSelectedItem="{Binding SelectedFirstNestedGridOrderDetails, Mode=TwoWay}"

                            FirstNestedSelectedItems="{Binding FirstNestedGridSelectedItems , Mode=TwoWay}"

                            FirstNestedCurrentItem="{Binding FirstNestedCurrentDetails,Mode=TwoWay}"/>

Sample Location: SfDataGrid_MasterDetailsView.zip

Regards,

Farjana Parveen A





Hello, 

i have the same problem trying to binding to a property of current detail row. I would need to download the sample SfDataGrid_MasterDetailsView.zip but it's unavailable.

Thanks in advance


MA Mohanram Anbukkarasu Syncfusion Team December 17, 2020 04:59 AM UTC

Hi Nacho, 

Thanks for using Sycfusion products.  

You can download the sample from the following link. 


Please let us know if you require any other assistance from us.  

Regards, 
Mohanram A. 


Loader.
Live Chat Icon For mobile
Up arrow icon