consume api web

Hi, is posible change "Items" name? or better question: is for me this approach?

This is my result json:

Image_8551_1723262076468


my web:

Image_6205_1723262024953


4 Replies 1 reply marked as answer

PS Prathap Senthil Syncfusion Team August 12, 2024 02:21 PM UTC

Hi Sergio Ayala,


Based on your query  we would like to clarify that ,we have provided support for various types adaptor which will be used to fetch data from different API server end and bind it to Grid. While using SfDataManager and Adaptor, only current page records will be fetched from server and paging operations will be handed in on demand concept. Please find the list of adaptors from below


Reference: Adaptors in Blazor DataManager Component | Syncfusion

So, if you have a JSON object with properties result and count, we suggest using the URL Adaptor.

If this still doesn’t meet your requirements, could you please confirm? Are you asking if it is possible to change the name of the 'Items' key in the JSON response? If so, could you clarify where and how you would like this change to be implemented?


Regards,
Prathap Senthil


Marked as answer

SA Sergio Ayala replied to Prathap Senthil August 13, 2024 12:18 AM UTC

yes, the approach for me is "Url adaptor



SA Sergio Ayala replied to Prathap Senthil August 13, 2024 05:50 AM UTC

Ok, I understand that the adapter I should use is "WebApiAdaptor" but:

1- does it matter if my json says "results" instead of "result"?

2- how do I bind each column? this is my json:


Image_9603_1723528138573

Image_3787_1723528172245

   <GridColumn Field="@nameof(Instruction.Id)" HeaderText="Order ID" IsPrimaryKey="true"></GridColumn>


my web show the header, but no columns:

Image_5937_1723528251671



PS Prathap Senthil Syncfusion Team August 13, 2024 02:02 PM UTC

No, when using the UrlAdaptor, you need to follow the standard format that UrlAdaptor expects. The response should be a JSON object with the properties result and count, which represent the collection of entities and the total number of records, respectively. The sample response object should look like this:

{

    "result": [{..}, {..}, {..}, ...],

    "count": 67

}

 


Similarly, the WebApiAdaptor expects a JSON response from the server. The response object should contain the properties Items and Count, where Items is the collection of entities and Count is the total count of the entities. The sample response object should look like this:

{

    "Items": [{..}, {..}, {..}, ...],

    "Count": 830

}

 


We suggest achieving your requirement using one of the adapters listed above with a standard format URL. If this does not meet your needs or if you have customized API endpoints, we recommend using the Custom Adapter with HttpClient to fulfill your requirements. We have already discussed this in the forum thread linked below, please refer to it for further information.

Grid API connection | Blazor Forums | Syncfusion


Loader.
Up arrow icon