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.
Unfortunately, activation email could not send to your email. Please try again.

SfDataGrid how to update ItemsSource after deleting SelectedItems

Thread ID:

Created:

Updated:

Platform:

Replies:

119214 May 22,2015 02:40 PM May 25,2015 02:42 AM Xamarin.Android 2
loading
Tags: General
Michel Uiterwijk
Asked On May 22, 2015 02:40 PM

Hi all,

I have a collection of custom objects that I bind to a SfDataGrid with a Multiple SelectionMode.
In a delete button event I delete those selected objects in the collection and rebind it to the grid.
However the grid doesn't update accordingly. I tried setting ItemsSource to null before but this causes a crash.

=== code to fill the grid

_List = datamodel.GetProducts();
_Grid = new SfDataGrid(this);
_Grid.ItemsSource = list;

==== and in delete event

var selected = _Grid.SelectedItems.Cast<Product>().ToList();
foreach (var product in selected)
     _List.Remove(product);
_Grid.ItemsSource = _List;

=====

Is there an update method on the grid? Or am I missing something?

Kind regards,
Michel.

P.S.: I put this thread in General because there is no SfDataGrid option in the Control dropdown.

Michel Uiterwijk
Replied On May 22, 2015 03:20 PM

Hi all,

After some real digging into the issue I found that everything works when the list is an ObservableCollection.
There is the magic as the grid automatically responds to changes in the list.

Hope this helps others as well... ;-)

Cheers, Michel.

Saranya CJ [Syncfusion]
Replied On May 25, 2015 02:42 AM

Hi Michel,

Thank you for your update. Please let us know if you require any other assistance on this.

Regards,
Saranya

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;