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"}]
---
[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>
|
<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>
|
|
"value":[{"OrderID":10248},{"OrderID":10249},{"OrderID":10250},{"OrderID":10251},...
|
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