ListView and remote data binding

I'm trying to use a ListView with remote data binding to a REST API for CRUD operations.

I've tried to follow the documentation but it uses deprecated APIs (SfListView.AddItem, SfListView.DeleteItem).

Question 1
Is there updated documentation to describe how to use non-deprecated APIs for remote data binding with a ListView?

Question 2
I have used a decompiler to figure out how to use the associated DataManager to execute CRUD operations (without using the deprecated APIs) - I'm not sure this is the correct way though. This works in that my API is called however the ListView doesn't update when list items change (which is what I expected). If I refresh the page, I can see that the list has changed. How do I use the ListView and remote binding to make changes appear in the list without refreshing the page?

I've attached a minimal example to reproduce my problem including a GIF animation of how it currently works.

Attachment: SfBlazorApp_d0c734e6.7z

4 Replies

SS Sharon Sanchez Selvaraj Syncfusion Team February 3, 2021 02:30 PM UTC

 
Thanks for contacting Syncfusion Support. 
 
We checked your requirements with ListView component. Currently we don’t have support for performing CRUD operations with ListView using Data Manager. We suggest you to use ListView AddItem and RemoveItem methods to add and remove the list items respectively.  
 
Please find the sample code snippet to achieve your requirement. 
 
List<Person> item = new List<Person>{ 
            new Person {Id = 1, Name = "A New Person"} 
            }; 
List.AddItem(item); 
 
Please refer the below link for the updated changes made in Blazor ListView. 
 
 
However, we are validating your issue with CRUD operations requirement and we will update the further details by February 9th, 2021. 
 
Please get back to us if you need further assistance. 
 
Regards, 
 
Sharon Sanchez S. 
 



SS Sharon Sanchez Selvaraj Syncfusion Team February 9, 2021 01:31 PM UTC

Hi Dario, 

We have checked with your requirement of CRUD operations in ListView. When using DataManager, the values gets updated in the database. To update the component, kindly use the AddItem and the RemoveItem method of ListView as suggested before.  

Please find the documentation link attached here for your reference. 


Please get back to us if you need any further assistance. 

Regards, 

Sharon Sanchez S. 



DA Dario February 24, 2021 08:25 AM UTC

Hi Sharon

Thanks for the responses. I don't find them 100% helpful.

The methods you've recommended using AddItem and RemoveItem are deprecated APIs. I did read the release notes you linked to and I could use the new RemoveItems method (instead of RemoveItem) but there doesn't seem to be a replacement for AddItem.

I understand that using the CRUD operations through ListView applies changes to the database. Again, the methods you've suggested using to update the ListView component are deprecated - they may be removed from a future release. Similarly, the documentation link you sent (https://blazor.syncfusion.com/documentation/listview/how-to/add-and-remove-list-items-from-listview/) describes an approach to adding/removing list items via the data source bound to the ListView.DataSource property. This is not exposed when using the CRUD approach with SfDataManager.

My overriding point is the guidance around using ListView with a REST API for CRUD operations is very confusing and simply doesn't work as documented in your help.


SS Sharon Sanchez Selvaraj Syncfusion Team February 26, 2021 03:57 PM UTC

Hi Dario, 

Sorry for the inconvenience.  

We would like to mention that AddItem has been deprecated in ListView from 18.3 release. Please refer to the following release notes. 


However, we have considered the requirement to provide support for updating the item in the ListView as a feature. This feature will be included in any of our upcoming releases.  

Please track the following feedback link to know the status of this issue. 


Please get back to us if you need further assistance. 

Regards, 

Sharon Sanchez S. 
 


Loader.
Up arrow icon