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

GridDataControl bind to selected rows

Hi,
 
I'm using MVVM to bind my collection to a grid, I can get the current item by using ICollectionView, however I need to allow the grid to select multiple rows, and so I need to be notified when the selection changes, but I can't bind to the SelectedItems property as it's not a dependency property, so is there a way to achieve this?
 
Ideally I would like to bind a property of each item to the 'selected' state for the corresponding grid row.
 
Thanks,
 
Brian

1 Reply

TV Thangapriya V Syncfusion Team June 4, 2013 12:27 PM UTC

Hi Brian,

Sorry for the delay caused.

We have analyzed your query. You cannot bind the SelectedItems property of the GridDataControl. However you can get the selected items by using SelectedItems.CollectionChanged event. You can refer the following code snippet for this.

 

Code snippet[C#]:

 

grid.SelectedItems.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(SelectedItems_CollectionChanged);

 

void SelectedItems_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)

        {

            if (e.NewItems != null)

            {

                foreach (var item in e.NewItems)

                {

                    var record = item as Data;

                    Console.WriteLine("Customer Id" + " "+ record.CustomerID);

                }

            }

        }

 

 

We have prepared a sample based on this. And you can find the sample in the following location.

Please let us know if you have any queries.

Regards,

Thangapriya



GridDataControlICollectionView 1_7da67ef8.zip

Loader.
Up arrow icon