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

SfDataGrid elements and Listbox objects interaction

Hello,

I have been trying to get a Listbox to store objects which contains the elements of a SfDataGrid and then, let the user fill the SfDataGrid with the data stored in the object by clicking the Listbox item. The problem I am facing is that once I assign new values to the SfDataGrid elements to create a new object, the values of the already created object (which is already in the Listbox) have their values changed too. How can I avoid that?

What I am doing: I am getting the SfDataGrid's elements through the ItemsSource property and adding them to a new List, which is what my object stores. To get the elements back to he SfDataGrid, I am adding the elements back from this list to a new instance of my view model's ObservableCollection and reassigning the DataContext to this view model. The ItemsSource is also reassigned, but to the ObservableCollection.

Thank you.

2 Replies

SP Shobika Palani Syncfusion Team February 27, 2019 01:23 PM UTC

Hi Pedro, 

Thank you for contacting Syncfusion Support. 

Currently we are trying to reproduce the reported issue from our end and we will update you with more details on 1st March,2019. 

Regards,
Shobika. 



SP Shobika Palani Syncfusion Team March 1, 2019 01:28 PM UTC

Hi Pedro, 

Thanks for your patience. We have prepared a simple sample based on your query and we have tried to replicate the issue that you were reported.  

Please find the demo sample and video from the below link 
Sample Link: 

Video Link: 

Can you please confirm whether you are reporting the issue that we are have replicated in the above video? If yes, this is because, you are creating new instance for viewmodel each time, due to this, the reported issue occurs. Instead, you can directly access existing datacontext of datagrid and add selected item from listbox. If the reported issue is different from the one we replicated, please revert us with the modified sample/Video illustrating the replication procedure, in order to investigate further and provide appropriate solution at earlier. 

Regards, 
Shobika. 


Loader.
Up arrow icon