var dmProyectoSubactivities= ej.DataManager({ url: baseUrl + "Kanban/GetProjectSubactivities", adaptor: new ej.UrlAdaptor(), }); var queryProyectoSubactivity = new ej.Query().addParams("IdProjectActivity", 1); var dmSubactivities = ej.DataManager({ url: baseUrl + "Kanban/GetSubactivities", adaptor: new ej.UrlAdaptor(), }); $("#gridSubtactividades").ejGrid({ dataSource: dmProyectoSubactivities, query: queryProyectoSubactivity, ... columns: [ { field: "IdSubactivity", headerText: "Subactivity", foreignKeyField: "ID", foreignKeyValue: "Name", dataSource: dmSubactivities}, ... ], load:"onLoad" }); } } <script type="text/javascript"> function onLoad(args) { var len = this.model.columns.length; for (var i = 0; i < len; i++) { if (this.model.columns[i].field == "IdSubactivity") { var IdActivity = 1; this.model.columns[i].dataSource.dataSource.headers = [{ data: IdActivity }] //pass the additional parameter using headers only for columns. } } } </script> [controller.cs] public JsonResult GetSubactivities(Syncfusion.JavaScript.DataManager dm) { var param = System.Web.HttpContext.Current.Request.Headers["data"]; //we will get the additional data here ... } |
$("#gridSubtactividades").ejGrid({ dataSource: dmProyectoSubactivities, query: queryProyectoSubactivity, ... columns: [ ... { field: "IdSubactivity", headerText: "Subactivity", foreignKeyField: "ID", foreignKeyValue: "Name", dataSource: dmSubactivities}, ... ], load:"onLoad" }); } } </script> <script type="text/javascript"> function onLoad(args) { var len = this.model.columns.length; for (var i = 0; i < len; i++) { if (this.model.columns[i].field == "IdSubactivity") { var IdActivity = 1; this.model.columns[i].dataSource.adaptor = new customAdaptor(); //define the custom adaptor in load event this.model.columns[1].dataSource.dataSource.headers = [{ data: IdActivity }] } } } var customAdaptor = new ej.UrlAdaptor().extend({ processResponse: function (data, ds, query, xhr, request, changes) { return data.result; }, }); </script> [controller.cs] public JsonResult GetSubactivities(Syncfusion.JavaScript.DataManager dm) { var param = System.Web.HttpContext.Current.Request.Headers["data"]; DataOperations ds = new DataOperations(); IEnumerable datos = GetSubactivities().Where(x => x.IdActivity == Convert.ToInt16(param)).ToList(); ... result.result = datos; result.count = datos.AsQueryable().Count(); return Json(result, JsonRequestBehavior.AllowGet); } |
Hi again,
I already got pass parameter in headers, but now, when I need edit for add new item , the dropdown is empty
Also, the grid has a different style, why? How can I set the usual style?
Thanks!