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.

SfListView + DataSource + Realm example

Thread ID:

Created:

Updated:

Platform:

Replies:

131552 Jul 16,2017 10:08 PM May 30,2018 08:50 AM Xamarin.Forms 7
loading
Tags: SfListView
seven
Asked On July 16, 2017 10:08 PM

Hi,

Is there any example with SfListView + DataSource + Realm(Database) + MVVM.
I want to know the correct way to use SfSlistView with those to CRUD and Filter.

I tried but I don't know it's the correct way.

1. I tried to get Realm.All<obj> to ObservableCollection.
2. I set the collection to the listview binding ItemSource.
3. When deleting Item, If I only delete the Realm Object, and reassign the ItemSource to the Realm.All<obj>().ToObservableCollection. it won't refresh the listview, even though I set the DataSource.Refresh().
4. Right now I delete the item in the collection and realm object at the same time, but I don't think it's a good idea.

so is there any example to use all of those tech. to implement CRUD, Filter, Sorting function?

Dinesh Babu Yadav [Syncfusion]
Replied On July 17, 2017 05:56 AM

Hi Seven, 
 
Thank you for using Syncfusion Products. 
 
We have checked the reported requirement “SfListView with Realm sample in MVVM pattern” at our end and tried to implement the SfListView control with Realm in MVVM pattern but we are facing the following error “Fody/RealmWeaver: Class Contacts is a RealmObject but has no persisted properties” at our end. So, we have raised a ticket to the respective team to resolve the issue and you can find the link below. 
 
 
For your reference, we have attached the prepared sample in which SfListView with Realm in MVVM pattern has been implemented and you can download it from the below link. 
 
 
Could you please check with the above sample? If you could able to resolve the issue, we request you to modify the above sample and revert us if the requirement does not met with the additional information’s which would help us to analyze the requirement better and update you an appropriate solution. 
 
Regards, 
Dinesh Babu Yadav 


seven
Replied On July 19, 2017 02:03 AM

Hi,

I tried your sample, and I don't think line 78 can work.

contactsinfo = _realm.All<Contacts>() as ObservableCollection<Contacts>;

the cast will make contactsinfo null.


seven
Replied On July 19, 2017 11:28 PM

Hi,

I still suffer in this thread.

I tried a really easy sample.

Listview worked at Create item and Modify item. but when delete item, it didnt update the listview.

I checked the IEnumerableCollection changed after delete command.

Please give me a hand asap, thanks a lot!!


Attachment: code_snippet_87abda3c.rar

seven
Replied On July 20, 2017 01:29 AM

by the way,

I also use dataSource.Refresh and listview.RefreshView,

The UI display weird.

very suffer to me....


Muthu Kumaran Gnanavinayagam [Syncfusion]
Replied On July 23, 2017 11:50 PM

Hi Seven, 
  
Apologies for the delay. 
  
We have deeply analyzed the reported query “ListView items does not refresh after deleting the items from Realm collection” at our end. We would like to inform you that the SfListView refreshes the view only when it gets notification whether underlying collection is changed or modified. Adding/removing items through Realm doesn't notify whether the collection is changed and so the view does not update even while calling the RefreshView. So we have to store the realm objects under ObservableCollection(As it provides notification when collection changed) to refresh the view. 
  
For your assistance, we have attached the working sample link below, 
  
Please let us know if you further assistance. 
  
Regards, 
G.Muthu Kumaran. 


redhouane
Replied On May 27, 2018 04:42 AM

Hi,
I wonder why it works with the out of the box ListView

thanks in advance

Muthu Kumaran Gnanavinayagam [Syncfusion]
Replied On May 30, 2018 08:50 AM

Hi Redhouane, 
 
We would like to inform you that while modifying the IEnumerable collection(either adding or deleting items at runtime) will update the items list bound to the ItemsSource of ListView. However the View will not be updated as the source collection will not get notified regarding this change. We have checked the same with Xamarin.Forms ListView and found the similar behavior as stated earlier. So you need the store the underlying collection as ObservableCollection to perform Visual changes at runtime in ListView. 
 
Regards, 
G.Muthu kumaran. 


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.

;