SelectedItems property fro GridDataControl

Hi there, I am trying to bind SelectedItems property to a ObservableCollection in a view model with two way binding, but it looks like the ObservableCollection doesn't update when I select multiple items in the datagrid.

I looked at the grid documentation and looks like it has setter and getter, so why it doesn't work?

Thanks,

Kent

 


4 Replies

SM Saravanan M Syncfusion Team November 19, 2013 01:47 PM UTC

Hi Kent,

Sorry for the Delay caused,

We have analyzed your query. We don’t have direct support to bind the SelectedItems value in GridDataControl.Because SelectedItems property is not a DependencyProperty. However you can use CollectionChanged event to get SelectedItems Value.You can refer the below codesnippet to achieve your requirement.

Codesnippet[XAML]:

gdc.SelectedItems.CollectionChanged += (sender, e) =>

                {

                 

                };

 

 

If you want to bind the SelectedItems value.Please refer the below codesnippet.

Codesnippet[XAML]:

<syncfusion:GridDataControl x:Name="DataGrid" ItemsSource="{Binding GDCSource}"

                              ShowAddNewRow="False"

                              AutoPopulateColumns="False"

                              AllowSelection="Row"

                              ListBoxSelectionMode="MultiExtended"

                              local:GDCAttachedProperty.EnableSelectedItemBinding="True"

                              local:GDCAttachedProperty.SelectedItems="{Binding SelectedItems, Mode=TwoWay}"

                                   

                                    >

 

We have prepared a sample based on this, please find the attached sample below,

Please let us know if you have any queries,

Regards,

Saravanan.M



GridDataControlSample_SelectedItemsBinding_1ed717ad.zip


MS Mahesh SanthaMoorthy September 15, 2014 11:41 AM UTC

Hi Team,

I need to view the sample attached in the solution given.


CG Carey G. Butler March 8, 2015 02:24 PM UTC

The zip file is damaged.


SM Saravanan M Syncfusion Team March 9, 2015 05:53 AM UTC

Hi Butler,

Sorry for the inconvenience,

You can download the sample from below location.

Sample Location: GridDataControlSample_SelectedItemsBinding.zip

Regards,

Saravanan.M



Loader.
Up arrow icon