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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to load SfDataGrid dynamically with JSON data without POCO classes ?

Platform: Xamarin.iOS |
Control: SfDataGrid |
Published Date: July 6, 2017 |
Last Revised Date: July 7, 2017 |
Product Version: 13.4.0.53

JSON data cannot be bound directly to SfDataGrid. To bind SfDataGrid with JSON data, we must deserialize the JSON data to a bindable format. You can use the open source NuGet Newtonsoft.Json to serialize and deserialize JSON objects.

Xamarin.iOS have limitations in loading dynamic object (Expando object). Hence dynamic objects can be loaded only using dictionary collection. Refer the dynamic limitations for more details.

JSON data can be parsed into a dictionary collection using JsonConvert.DeserializeObject<List<Dictionary<string, object>>>(json_object).

You can then convert the list of dictionary objects to an observable collection if your data source need to respond to collection changes.

The List of Dictionary objects or the converted ObservableCollection can now be binded as ItemsSource of SfDataGrid.

Refer the below example in which the list of dictionary objects are converted as an ObservableCollection and bound to SfDataGrid.

ViewModel.cs

 

DynamicModel.cs

 

MainPage.cs

You can set the deserialized data collection to the SfDataGrid by using the below

Note: In order to apply sorting for JSON data, you have to customize the GridQueryableCollectionViewWrapper class and initialize the customized GridQueryableCollectionViewWrapper while setting the ItemSource to SfDataGrid.

Refer the below code example to customize the GridQueryableCollectionViewWrapper class.

 

MainPage.cs:

 

Sample Link: How to load SfDataGrid dynamically with JSON data without POCO classes?

 

 

2X faster development

The ultimate Xamarin UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon 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.Close Icon