Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
80
Disabling Enter key to Add new row
posted

Hi,

Currently I am working on Adding a new row in WebDataGrid.There are two columns.When I enter the value in two columns and press enter the row gets added.Also when I 

enter the value in one of the two column and press  enter then also the row gets added.What I want is when one of the column in filled and thenI press enter then the row should not be added in the grid. How can I disable row adding on Enter key press and also how to add the new row when I fill the column and loose focus from that row or I click anywhere in the windowthe row should automatically be added?

Below is my javascript code on Exited Edit Mode in row adding.Please suggest.

function dgAdjustmentHeaderOnInsert(sender, eventArgs) {

var grid = $find("<%=dgAdjustmentHeader.ClientID%>");
var gridBehaviors = grid.get_behaviors();
var aj_id = null;
var textValue = document.getElementById("ctl00_ContentPlaceHolder1_txtDescription").value;
var aj_code = eventArgs.getCell().get_row().get_cellByColumnKey("AJ_CODE").get_value();
var aj_name = eventArgs.getCell().get_row().get_cellByColumnKey("AJ_NAME").get_value();
var event = eventArgs.get_browserEvent();
if (textValue != null || textValue != "") {
eventArgs.getCell().get_row().get_cellByColumnKey("AJ_DESC").set_value(textValue);
}

if (aj_code != null && aj_name != null) {
var enter_key_code = event.keyCode;
if (enter_key_code != null && enter_key_code == 13) {
abmAPI.insertExpenseAdjustmentHeader(aj_id, (eventArgs.getCell().get_row().get_cellByColumnKey("AJ_NAME").get_value() == null ? "" : eventArgs.getCell().get_row().get_cellByColumnKey("AJ_NAME").get_value()),
(eventArgs.getCell().get_row().get_cellByColumnKey("AJ_CODE").get_value() == null ? "" : eventArgs.getCell().get_row().get_cellByColumnKey("AJ_CODE").get_value()), (eventArgs.getCell().get_row().get_cellByColumnKey("AJ_DESC").get_value() == null ? "" : eventArgs.getCell().get_row().get_cellByColumnKey("AJ_DESC").get_value()),
eventArgs.getCell().get_row().get_cellByColumnKey("MI_ID").get_value(), insertExpenseAdjustmentHeaderHandler_12);
alert("Row inserted successfully");
aj_id = document.getElementById("txtRowUpdated").value;
var year = eventArgs.getCell().get_row().get_cellByColumnKey("MI_YEAR").get_value();
var mi_id = eventArgs.getCell().get_row().get_cellByColumnKey("MI_ID").get_value();
eventArgs.getCell().get_row().get_cellByColumnKey("AJ_ID").set_value(aj_id);
window.frames[0].document.location = "ExpenseAdjustmentDetails12.aspx?AJ_ID=" + aj_id
+ "&MI_ID=" + mi_id + "&YEAR=" + year;

}
}
else {
if (event == null || event.keyCode == 13)
alert("Row not inserted.Please enter adjustment completely before saving.");
}
document.getElementById("ctl00_ContentPlaceHolder1_txtDescription").value = "";

}

Parents Reply Children
No Data