<script type="text/javascript">
$(function () {
$("#Grid").ejGrid({
................
columns: [
{ field: "EmployeeID", foreignKeyField: "EmployeeID", foreignKeyValue: "FirstName", dataSource: window.employeeView, width: 75, headerText: "First Name" ,editType:"dropdownedit",editParams: { enableFilterSearch: true }},
{ field: "Freight", headerText: 'Freight', textAlign: ej.TextAlign.Right, editType: ej.Grid.EditingType.Numeric, width: 80, format: "{0:c2}" },
]
});
});
</script> |
$("#order_grid").ejGrid({
……………………….
editSettings: { allowDeleting: true, allowEditing: true, allowAdding: true, editMode: 'batch', rowPosition: "bottom" },
…………….
columns: [
{ field: "OrderID", width: 200, isPrimaryKey: true },
………..
]
});
Server End
public ActionResult UpdateCustom(List<EditableOrder> changed, List<EditableOrder> added, List<EditableOrder> deleted)
{
…………………
if (added != null)
OrderRepository.ComplexAdd(added);
var data = OrderRepository.GetComplexRecords();
return Json(data, JsonRequestBehavior.AllowGet);
}
public static void ComplexAdd(List<EditableOrder> record)
{
int insertposition = GetAllRecords().Count(); // get the total record count
foreach (var temp in record)
GetComplexRecords().Insert(insertposition, temp);
} |