var dataManager2 = ej.DataManager({
url: "/attribute-set/grid",
crossDomain: true
});
dataManager2.adaptor = new ej.UrlAdaptor();
var query = new ej.Query().take(5);
var dataObj = dataManager2.executeQuery(query); //Request the webservice
dataObj.done(function (e) {
console.log(e.result);
$("#grid2").ejGrid({
dataSource: e.result.results,
allowPaging: true,
allowSorting: true,
allowFiltering: true,
columns: ["ID", "CreatedAt", "DeletedAt", "UpdatedAt", "Name"],
});
});
$(function () { var dataManager = ej.DataManager({ url: "/Home/DataSource", adaptor: new ej.UrlAdaptor() }); $("#Grid").ejGrid({ dataSource: dataManager, allowPaging: true, filterSettings: {filterType: "menu"}, allowFiltering: true, allowSorting: true, columns: [ { field: "OrderID", isPrimaryKey: true, headerText: "Order ID" }, { field: "EmployeeID", headerText: 'Employee ID' }, { field: "CustomerID", headerText: 'Customer ID' }, { field: "Freight", headerText: 'Freight', format: "{0:C}" }, { field: "ShipCity", headerText: 'Ship City' }, ] }); }); |
Thank you, it's working. It will be good to have info about server response somewhere in the documentation. In my case, it didn't work because I didn't know how to prepare server answer.
Server response should be a JSON which contains two fields:
count - a total of found records
results - an array of your columns data
Is it right?
Ok, thank you