Odata .NET 6.0

Hello,

I try so use Odata in SfGrid but I get 'No records to display', what am I forgetting ?

Microsoft.AspNetCore.OData 8.0.8 & Syncfusion 9.4.0.55

OData endpoint is reponding

curl -X GET https://localhost:5001/api/odata/FinAccounts?$select=name,FinAccountId 
[{"Name":"GALET MARCEL","FinAccountId":"C1GALEMA"},{"Name":"GALET MARCEL","FinAccountId":"F5GALEMA"}]

My breakpoint is stopping in the controller, and the controller is returning 2 FinAccounts.
But SfGrid is empty,
---
[HttpGet]
[EnableQuery]
public IQueryable<FinAccount> GetAll()
{
    return _dbContext.FinAccounts;
}
---
<SfGrid TValue="FinAccount" >
    <SfDataManager Url="/api/odata/FinAccounts" Adaptor="Adaptors.ODataV4Adaptor" ></SfDataManager>
    <GridColumns>
        <GridColumn Field=@nameof(FinAccount.Name) HeaderText="Name" />
    </GridColumns>
</SfGrid>




3 Replies

MS Monisha Saravanan Syncfusion Team March 10, 2022 01:20 PM UTC

Hi Jean-François Hermans, 
  
Greetings from Syncfusion support. 
  
We have analyzed your query and prepared an sample based on your query. But we could not able to reproduce the reported issue at our end. Kindly check the attached sample for your reference. 
  
  
<SfGrid TValue="EmployeeData" ID="Grid" AllowPaging="true"> 
    <SfDataManager Url=https://services.odata.org/V4/Northwind/Northwind.svc/Orders/?$select=OrderID,CustomerID Adaptor="Adaptors.ODataV4Adaptor"></SfDataManager> 
    <GridColumns> 
        <GridColumn Field=@nameof(EmployeeData.OrderID) TextAlign="TextAlign.Center" HeaderText="Order ID" Width="120"></GridColumn> 
           <GridColumn Field=@nameof(EmployeeData.CustomerID) TextAlign="TextAlign.Center" HeaderText="Employee ID" Width="120"></GridColumn> 
    </GridColumns> 
</SfGrid> 
  
  
  
On analyzing further we suspect that the data format shared by you is different from OdataV4. 
  
"value":[{"OrderID":10248},{"OrderID":10249},{"OrderID":10250},{"OrderID":10251},... 
  
  
Kindly check the attached sample if the reported issue still persists then Kindly share the below details to validate further at our end. 
  
  • Share us the data format present in the OData service like as above.
  • If possible share us simple issue reproduceable sample or try to reproduce the issue on the above sample.
  
Kindly get back to us if you have further queries. 
  
Regards, 
Monisha 



JH Jean-François Hermans March 11, 2022 02:51 PM UTC

You are right, I didn't return odata formated.

My BaseController was decorated with an [ApiController] !

SfGrid is no more empty.

Correct format

{"@odata.context":"https://localhost:44398/odata/$metadata#FinAccounts(Name,FinAccountId)","value":[{"FinAccountId":"C1GALEMA","Name":"GALET MARCEL"},{"FinAccountId":"F5GALEMA","Name":"GALET MARCEL"},{"FinAccountId":"F5IGT","Name":"TEST"}]}

Thanks



MS Monisha Saravanan Syncfusion Team March 14, 2022 12:48 PM UTC

Hi  Jean-François Hermans,  

Thanks for the update. 

We are glad to hear that your query has been resolved. Kindly get back to us if you have further queries. As always we will be happy to assist you. 

Regards, 
Monisha 


Loader.
Up arrow icon