Hello,
am implementing SfDataManager as described here:
Custom Binding in Blazor DataGrid Component | Syncfusion
I am assigning an ObservableCollection to "DataSource" property in SfDataManager (as shown in the example implementation).
If "ReadAsync" is triggered and the ObservableCollection is returned as DataSource from the method the grid updates properly.
However if I update the ObservableCollection outside of the DataManager (e.g. in my ViewModel) I would expect that the grid updates also the same way as if I would assign the ObservableCollection via its DataSource property directly.
However that is not the case. It seems that if using SfDataManager the grid does not update as described here:
Observable Collection and INotifyPropertyChanged in Syncfusion Blazor
Kindly let me know what I have to do to update the grid if the ObservableCollection is updated.
Thank you
Daniel
Hi Daniel,
Based on the reported problem, we would like to clarify that when using the SfDataManager in the grid, there was a different property used apart from binding the data source collection directly to the grid's datasource property. We have added a NotifyCollectionChanged event for that datasource collection, which will trigger the event when the observable collection is modified. Therefore, when using the SfDataManager, data will only be updated when the ReadAsync method is called. This is the default behavior of the grid.
Regards,
Prathap s
Hello,
Thanks for the reply.
I am not sure if I understand properly. How can I ensure an ObservableCollection used with DataManager works the same way as if assigning it to the DataSource property directly.
Also you are mentioning calling ReadAsync Method. I am only aware of triggering if calling Refresh() method at the grid. This has negative side effects as eg selection is reset. Are there other ways to trigger ReadAsync().
Thank you
Daniel
Based on your query, we would like to inform you
that when using the grid Datasource property, we have added a
NotifyCollectionChanged event on our source side for that datasource
collection. This event will trigger when the observable collection is modified.
However, when using the SfDatamanager for fetching data, it is specifically
used for the connector data mediator with the grid . Therefore, it is not
feasible to achieve your requirement using the SfDatamanager. We suggest
achieving your requirement by calling the grid refresh method to execute the
Readasync function. This is the default behavior. Thank you for your
understanding.
Thank you for clarification.
The reason why I am using the DataManager is because I have to implement custom sort logic. You suggest using it to other customers in the forum who had similar requirements.
Is there an other way of implementing custom sort logic? The „Sorting“ event is unfortunately not providing a IsHandled=True property for that. I can just cancel it.
Calling Grid.Refresh e.g also resets row selection. Is there a kind of soft refresh?
Thank you
Daniel
Hi Daniel,
Thanks for an update.
From your query, we suspect that you’re facing issue in custom sorting. We
suggest you to overcome the reported issue by using SortComparer property in
GridColumn to customize the sort action. Kindly refer the attached
documentation link for your reference.
Reference: https://blazor.syncfusion.com/documentation/datagrid/sorting#custom-sorting
If you’re facing issue or any other further queries, please
get back to us.
Regards,
Sarvesh