BoldSignA modern eSignature application with affordable pricing. Sign up today for unlimited document usage!
Hi There,I have ejGrid implementation which loads all data at onetime, this increases resonse time and bandwidth of my website.Earlier I was directly adding a json formated data to DataSource of my grid. After doing some search and demo I have implemented below code and I can see that functions are getting triggered but grid is not showing any data.Am I missing anything?var dataManager = ej.DataManager({ url: config.serviceUrl + '/GetAllProjectsPageData/1', adaptor: new ej.WebApiAdaptor(), crossDomain: true });$("#ProjectsListGrid").ejGrid({dataSource: dataManager,allowPaging: true,columns: ["ProjectID","ProgramName","Location","Description"],});I check Network traffic and my WebAPI responding back data but I think it has something with Formatter as my WebAPI is responding data in OData form and I guess I need to convert them back to JSON form.How can I achieve this without changing formation on my WebAPI side?I appreciate your help.ThanksRushi
<div id="Grid"></div> <script type="text/javascript"> $(function () { var DataManager = ej.DataManager({ url: "/api/Orders", adaptor: new ej.WebApiAdaptor(), crossDomain: true, }); $("#Grid").ejGrid({ dataSource: DataManager, allowPaging: true, editSettings: { allowEditing: true, allowAdding: true, allowDeleting: true }, toolbarSettings: { showToolbar: true, toolbarItems: [ej.Grid.ToolBarItems.Add, ej.Grid.ToolBarItems.Edit, ej.Grid.ToolBarItems.Delete, ej.Grid.ToolBarItems.Update, ej.Grid.ToolBarItems.Cancel] }, columns: [ { field: "OrderID", isPrimaryKey: true, headerText: "Order ID", textAlign: ej.TextAlign.Right, validationRules: { required: true, number: true }, width: 90 }, { field: "CustomerID", headerText: 'Customer ID', validationRules: { required: true, minlength: 3 }, width: 90 }, { field: "EmployeeID", headerText: 'Employee ID', textAlign: ej.TextAlign.Right, width: 80, validationRules: { number: true } }, { field: "Freight", headerText: 'Freight', textAlign: ej.TextAlign.Right, editType: ej.Grid.EditingType.Numeric, editParams: { decimalPlaces: 2 }, validationRules: { range: [0, 1000] }, width: 80, format: "{0:C}" }, { field: "ShipCountry", headerText: 'Ship Country', width: 90 } ] }); }); public class OrdersController : ApiController { // GET api/orders NorthwindDataContext db = new NorthwindDataContext(); public PageResult<Order> Get(ODataQueryOptions opts) { List<Order> ord = db.Orders.ToList();
return new PageResult<Order>(opts.ApplyTo(ord.AsQueryable()) as IEnumerable<Order>, null, ord.Count); |
<script type="text/javascript"> $(function () { var DataManager = ej.DataManager({ url: "/api/Orders", adaptor: new ej.UrlAdaptor() }); $("#Grid").ejGrid({ dataSource: DataManager, allowPaging: true, editSettings: { allowEditing: true, allowAdding: true, allowDeleting: true }, toolbarSettings: { showToolbar: true, toolbarItems: [ej.Grid.ToolBarItems.Add, ej.Grid.ToolBarItems.Edit, ej.Grid.ToolBarItems.Delete, ej.Grid.ToolBarItems.Update, ej.Grid.ToolBarItems.Cancel] }, columns: [ { field: "OrderID", isPrimaryKey: true, headerText: "Order ID", textAlign: ej.TextAlign.Right, validationRules: { required: true, number: true }, width: 90 }, { field: "CustomerID", headerText: 'Customer ID', validationRules: { required: true, minlength: 3 }, width: 90 }, { field: "EmployeeID", headerText: 'Employee ID', textAlign: ej.TextAlign.Right, width: 80, validationRules: { number: true } }, { field: "Freight", headerText: 'Freight', textAlign: ej.TextAlign.Right, editType: ej.Grid.EditingType.Numeric, editParams: { decimalPlaces: 2 }, validationRules: { range: [0, 1000] }, width: 80, format: "{0:C}" }, { field: "ShipCountry", headerText: 'Ship Country', width: 90 } ] }); }); </script>
---------------------------------------------------------------------------------------------------------
public class OrdersController : ApiController {
// GET api/orders NorthwindDataContext db = new NorthwindDataContext(); [HttpPost] public DataResult Post(DataManager dm) { DataResult result = new DataResult(); result.result = db.Orders.Skip(dm.Skip).Take(dm.Take).ToList(); result.count = db.Orders.Count(); return result; }
//GET api/orders/5 [HttpGet] public string Get(int id) { return "value"; } public class DataResult { public IEnumerable<Order> result { get; set; } public int count { get; set; } |