I'm using Syncfusion for a simple web page with a grid. My web service that feeds the grid initially returned just a JSON array, but after reading through the Syncfusion docs, I modified my JSON response to match what is required for the UrlAdapator. However, after doing this it's still not working - actually, I just get a blank page when I open the web page.
Here is the code to create the grid with data binding:
const SERVICE_URI = 'http://localhost:4000/users';
var data = new DataManager({
url: SERVICE_URI,
adaptor: new UrlAdaptor
}).executeQuery(new Query());
var grid = new ej.grids.Grid({
dataSource: data,
columns: [
{ field: 'UserName', headerText: 'Username', textAlign: 'Right', width: 120, type: 'string' },
{ field: 'FirstName', width: 140, headerText: 'First Name', type: 'string' },
{ field: 'LastName', headerText: 'Last Name', textAlign: 'Right', width: 120, format: 'string' }
],
actionFailure: (e) => {
var span = document.createElement('span');
grid.element.parentNode.insertBefore(span, grid.element);
span.style.color = "#FF0000"
span.innerHTML = "Error";
},
height: 180
});
Here's an example of the JSON response from http://localhost:4000/users:
{"result": [{"UserName":"johnd","FirstName":"John","LastName":"Doe"},{"UserName":"doeJ","FirstName":"John","LastName":"Doe"},{"UserName":"jdoe","FirstName":"Jane","LastName":"Doe"}],"count": 3}
Any ideas for how to make my response work with an adapter or vice-versa?