
|
<ejs-grid id="Grid1" allowPaging="true">
<e-data-manager url="/api/Orders/" adaptor="WebApiAdaptor" crossDomain="true"></e-data-manager> //Remove offline property
...
</ejs-grid> |
|
public void ConfigureServices(IServiceCollection services)
{
// Add framework services.
services.AddMvc().AddJsonOptions(options =>
{
options.SerializerSettings.ContractResolver = new Newtonsoft.Json.Serialization.DefaultContractResolver();
});
} |
Hi Patrik,
Thanks for using Syncfusion products.
We suspect that you are facing serialization problem. To render the Grid data, column’s field names and the property name in the data source should be same. After that Grid will be rendered with data. Due to serialization problem, your field name’s casing is changed and so there is a mismatch in the column’s field and datasource’s property names, this is why you don’t have data in Grid.
To overcome this serialization problem, we suggest you to add the JsonOutputFormatter options under the Startup.cs file. JsonOutputFormatter is a TextOutputFormatter for JSON content. Please refer the sample below,
Index.cshtml
<ejs-grid id="Grid1" allowPaging="true"><e-data-manager url="/api/Orders/" adaptor="WebApiAdaptor" crossDomain="true"></e-data-manager> //Remove offline property...</ejs-grid>
Startup.cs
public void ConfigureServices(IServiceCollection services){// Add framework services.services.AddMvc().AddJsonOptions(options =>{options.SerializerSettings.ContractResolver = new Newtonsoft.Json.Serialization.DefaultContractResolver();});}
Please get back to us if you need further assistance.
Regards,Venkatesh Ayothiraman.
| [Index.cshtml] <script> function selectRow(args) { ... if (args.data !== undefined) { new ej.data.DataManager({ url: '/api/Orders/', adaptor: new ej.data.WebApiAdaptor() }).executeQuery(new ej.data.Query().where('ParentAccessoryID', 'equal', args.data.OrderID).take(3)).then((e) => { ... }); } } </script> [OrdersController.cs] public object Get() { var queryString = Request.Query; var data = OrdersDetails.GetAllRecords().ToList(); ... string filter = queryString["$filter"]; //filtering if (filter != null) { var newfiltersplits = filter; var filtersplits = newfiltersplits.Split('(', ')', ' '); var filterfield = filtersplits[0]; var filtervalue = filtersplits[2]; switch (filterfield) { case "ParentAccessoryID": data = (from cust in data where cust.ParentAccessoryID.ToString() == filtervalue.ToString() select cust).ToList(); break; } } return take != 0 ? new { Items = data.Skip(skip).Take(take).ToList(), Count = data.Count() } : new { Items = data, Count = data.Count() }; } |