Dear all, I have a question about the JSON processing capabilities of the Syncfusion Grid component (EJS / EJ2). I would like to display the contents of a JSON file in the Grid. The JSON file is the result of an API-call. I followed the instructions presented in the documentation, also taking into account this article here in the community forum. I created the following helper method for converting the JSON file:
public static object DeserializeJson(string jsonInput){
if (jsonInput == null) throw new ArgumentNullException(nameof(jsonInput));
var obj = JsonConvert.DeserializeObject<object>(anotherJsonTest);
return obj;
}
The grid is on the Index.cshtml page, using the following code:
<div class="grid-view">
@Html.EJS().Grid("Grid").DataSource((IEnumerable<object>)ViewBag.DataSource).Height(500).Render()
</div>
After some disappointing errors, I considered using a less intricate JSON file to be passed to both the conversion method and the grid. Using the following sample lead to a proper display of items.
[
{
"_id": {
"$oid": "5968dd23fc13ae04d9000001"
},
"product_name": "sildenafil citrate",
"supplier": "Wisozk Inc",
"quantity": 261,
"unit_cost": "$10.47"
},
{
"_id": {
"$oid": "5968dd23fc13ae04d9000002"
},
"product_name": "Mountain Juniperus ashei",
"supplier": "Keebler-Hilpert",
"quantity": 292,
"unit_cost": "$8.74"
},
{
"_id": {
"$oid": "5968dd23fc13ae04d9000003"
},
"product_name": "Dextromathorphan HBr",
"supplier": "Schmitt-Weissnat",
"quantity": 211,
"unit_cost": "$20.53"
}
]
I know that the grid appears to be working, however, reverting back to actual the JSON file I intended to process in the beginning, nothing was displayed in the grid. I checked the console in the Browser (Google Chrome) for errors and found the following error message:
constants.js:93 Uncaught TypeError: Cannot read property 'matrix' of undefined
at e.onFocus (constants.js:93)
Considering the above error message, I was wondering if there were processing limitations regarding the complexity (level of dimensions) of the JSON file passed to the grid. What is the exact meaning behind the error message above and how can I avoid this.
Are there any alternatives I could apply to display the information contained in complex JSON files in the grid.
It would be grand if you could provide some insight into this matter.
Thanks a mil in advance. Please do get in touch if you require additional information.
Kind regards
C.