BoldSignA modern eSignature application with affordable pricing. Sign up today for unlimited document usage!
Hi Mike,
Thanks for using Products.
We are glad to let you know that we have created a sample based on your requirement and the same can be downloaded from below link.
Sample: http://www.syncfusion.com/downloads/support/directtrac/general/UrlAdaptor1316899268.zip
In the above sample using DataManager we can bind data from server-side to Grid with On-demand Paging. And during sorting operation in Grid, sorted column details will be passed to server-side DataManager class by which we can perform sorting on data. Please refer the following code snippets.
("#Grid").ejGrid({ dataSource:ej.DataManager({ url: "Home/DataSource", updateUrl: "Home/Update", insertUrl: "Home/Insert", removeUrl: "Home/Delete", adaptor: "UrlAdaptor" }), ... })
public ActionResult DataSource(DataManager dm) {
var DataSource = OrderRepository.GetAllRecords(); DataResult result = new DataResult(); //To take only current page records result.result = DataSource.Skip(dm.Skip).Take(dm.Take).ToList(); result.count = DataSource.Count(); return Json(result, JsonRequestBehavior.AllowGet); } |
Also to bind the edited records in server-side we can use “updateUrl” property DataManager. Please refer the following code snippets.
("#Grid").ejGrid({ dataSource:ej.DataManager({ url: "Home/DataSource", updateUrl: "Home/Update", insertUrl: "Home/Insert", removeUrl: "Home/Delete", adaptor: "UrlAdaptor" }), ... }) public ActionResult Update(EditableOrder value) { OrderRepository.Update(value); var data = OrderRepository.GetAllRecords(); return Json(data, JsonRequestBehavior.AllowGet); } |
Please refer the following Online sample link for further reference on Editing in Grid.
http://js.syncfusion.com/demos/web/#!/azure/grid/Editing
Please let us know if you need any further assistance.
Regards,
Alan Sangeeth S
Hi Mike,
Thanks for using Products.
We are glad to let you know that we have created a sample based on your requirement and the same can be downloaded from below link.
Sample: http://www.syncfusion.com/downloads/support/directtrac/general/UrlAdaptor1316899268.zip
In the above sample using DataManager we can bind data from server-side to Grid with On-demand Paging. And during sorting operation in Grid, sorted column details will be passed to server-side DataManager class by which we can perform sorting on data. Please refer the following code snippets.
("#Grid").ejGrid({
dataSource:ej.DataManager({ url: "Home/DataSource", updateUrl: "Home/Update", insertUrl: "Home/Insert", removeUrl: "Home/Delete", adaptor: "UrlAdaptor" }),
...
})
public ActionResult DataSource(DataManager dm)
{
var DataSource = OrderRepository.GetAllRecords();
DataResult result = new DataResult();
//To take only current page records
result.result = DataSource.Skip(dm.Skip).Take(dm.Take).ToList();
result.count = DataSource.Count();
return Json(result, JsonRequestBehavior.AllowGet);
}
Also to bind the edited records in server-side we can use “updateUrl” property DataManager. Please refer the following code snippets.
("#Grid").ejGrid({
dataSource:ej.DataManager({ url: "Home/DataSource", updateUrl: "Home/Update", insertUrl: "Home/Insert", removeUrl: "Home/Delete", adaptor: "UrlAdaptor" }),
...
})
public ActionResult Update(EditableOrder value)
{
OrderRepository.Update(value);
var data = OrderRepository.GetAllRecords();
return Json(data, JsonRequestBehavior.AllowGet);
}
Please refer the following Online sample link for further reference on Editing in Grid.
http://js.syncfusion.com/demos/web/#!/azure/grid/Editing
Please let us know if you need any further assistance.
Regards,
Alan Sangeeth S
Hi Mike,
We are sorry for the inconvenience caused.
We have confirmed that the issue “In Grid column correct values are not binding during editing if the field name is numeric” is a defect. We have logged defect report for this and the fix for this issue will be included in 2014 Volume 2 Service Pack 3 release which will be available in end of September, 2014.
Please let us know if you have any queries.
Regards,
Alan Sangeeth S
Hi Mike,
Thanks for the update.
We would like to let you know that we can pass additional parameters to the server-side by adding the same to the Grid “query” property in “actionBegin” event of Grid. Please refer the following code snippets.
$("#Grid").ejGrid({ }); });
function beginHandler(args) { args.model.query.addParams("category", 3) } |
For your convenience we have created a sample and the same can be downloaded from below link.
Sample: http://www.syncfusion.com/downloads/support/directtrac/general/UrlAdaptor_(2)-1433878765.zip
Please let us know if you need any further assistance.
Regards,
Alan Sangeeth S
Hi Mike,
Thanks for the update.
We are happy to hear that your requirement has been achieved.
Please let us know if you need any further assistance. We will be happy to help you out.
Regards,
Alan Sangeeth S
Hi Mike,
Thanks for the update.
We suggest you to use ‘AutoGenerate columns’ feature of Grid to render all columns from Grid dataSource. We can enable ‘AutoGenerate columns’ feature by simply not mentioning the columns property of Grid. And to dynamically add more columns, we suggest you to destroy the grid and then re-render the Grid control. Please refer the following code snippets.
<input type="button" value="AddMoreColumns" onclick="AddColHandler()" />
function AddColHandler() { var obj = $("#Grid").ejGrid("instance"); obj.destroy() addCol = true, $("#Grid").ejGrid({ dataSource: ej.DataManager({ url: "Home/DataSource/?newCol=true", updateUrl: "Home/Update", insertUrl: "Home/Insert", removeUrl: "Home/Delete", adaptor: "UrlAdaptor" }), allowPaging: true, allowSorting: 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] }, actionBegin: "beginHandler", actionComplete: "complete" }) }
function beginHandler(args) { if (addCol == true) args.model.query.addParams("newCol", true)
} |
Also in AutoGenerate Columns Grid, since we cannot specify Primary Key column in columns property of Grid, we have added the primaryKey at the ‘actionComplete’ event of Grid. Please refer the following code snippets.
function complete(args) { if (args.requestType == "refresh") { var cols = this.model.columns.filter(function (e) { return (e.field == "OrderID") })[0]; var index = $.inArray(cols, this.model.columns); this.model.columns[index].isPrimaryKey = true; } } $("#Grid").ejGrid({ ... actionComplete:"complete" }); |
For your convenience we have created a sample and the same can be downloaded from below link.
Sample: http://www.syncfusion.com/downloads/support/directtrac/129706/EJGrid1699577499.zip
In the above sample on a button click event we have destroyed grid and re-rendered it with modified value for the url property of Grid DataManager to get additional columns.
Please let us know if you need any further assistance.
Regards,
Alan Sangeeth S
Hi Mike,
Thanks for the update.
Query 1: “Documentation for Grid destroy”
Please find the details about “destroy” method of Grid in the following online documentation.
http://help.syncfusion.com/UG/JS_CR/ejGrid.html#destroy
Query 2: “headerText, width and other column attributes”
We suggest you to set headerText, Width and other attributes in “actionComplete” event of Grid using “columns” method of grid. Please refer the following code snippets.
$("#Grid").ejGrid({ });
function complete(args) { ... $.each(args.model.columns, function (e, val) { val.headerText = val.field + " Column"; if (val.field == "Freight") { val.editType = "numericedit"; val.textAlign = "right"; } }) creat = false; gridObj.columns(args.model.columns); } } |
For your convenience we have created a sample and the same can be downloaded from below link.
Sample: http://www.syncfusion.com/downloads/support/directtrac/general/EJGrid826932419.zip
Please let us know if you have any queries.
Regards,
Alan Sangeeth S
Hi Mike,
We have modified the sample based on your requirement (“setting grid column properties using ajax post results”) and the same can be downloaded from below link.
Sample: http://www.syncfusion.com/downloads/support/directtrac/130131/EJGrid8269324191179122326.zip
In the above sample, at “load” event of Grid, we are setting Grid column properties from the ajax post result. Please refer the following code snippets.
$("#Grid").ejGrid({ load:"load", })
function load(args) { $.ajax({ url: "Home/ColumnData", type: "Post", data: { newCol: addCol }, async:false, //To prevent further execcution before setting column properties success: function (e) { args.model.columns= e; } }) }
public ActionResult ColumnData(bool newCol) { List<object> gridCol = new List<object>(); ... foreach (var temp in columns) { ... object obj = new { field = temp.Name, headerText = temp.Name + "Column", editType = colType, textAlign = align, visible = true };
gridCol.Add(obj); } return Json(gridCol, JsonRequestBehavior.AllowGet);
} |
If we misunderstood your requirement please get back to us with more information so that we could provide you a response as early as possible.
Please let us know if you have any queries.
Regards,
Alan Sangeeth S