Hi guys I am creating a web app with an editable jqGrid (v4.4) and by default when you are in edit mode (inline editing) and you press the Enter key it invokes the saveRow method of the jqGrid, which actually tries to save the row.
The problem is that I have been using a custom way of saving my rows and I only use saveRow after I do some other stuff first.
I created a keybinding for Enter like this:
$(document).keyup(function (e) {
if (e.keyCode == 13) {
if (lastsel) {
jQuery('#list').jqGrid('saveRow', lastsel, false, 'clientArray');
var rowData = jQuery('#list').jqGrid('getRowData', lastsel);
// alert(rowData);
// alert(JSON.stringify(rowData));
jQuery.post('Home/Save?inputEmployee=', JSON.stringify(rowData));
lastsel = false;
}
}
});
The problem is that it does both what jqGrid had defined for the binding AND what I do above.
Is there any way I can get rid of the previous binding for Enter before I use mine?
EDIT:
I inculed my HomeController Save method:
public void Save(string inputEmployee)
{
Employee employeeData = JsonConvert.DeserializeObject(inputEmployee.ToString(), typeof(Employee)) as Employee;
var context = new EmployeeDataContext();
Employee employee = context.Employees.Single(e => e.ID == employeeData.ID);
employee = employeeData;
context.SubmitChanges();
}
So what I do is I have created a LINQ to SQL model and I use it’s context to get/set data from/to database. So I thought I’d pass an Employee stringified object as a parameter and then deserialize it with my controller.
It seems to me that you chosen not the best way of implementation of your requirements. One can see from the code which you posted that you want to use local editing (
url: "clientArray"option of editRow), but you want additionally do some additional action after saving of the row. In the case the best choice could be to useaftersavefunccallback. So the call ofeditRowcould be something likeI was not sure how you wanted to send the data to the
Home/SaveURL. You usedinputEmployeeparameter without any value. You can adjust the above code corresponds to your exact requirements.