Hi,
I'm using a rad grid to display invoice items. The first column of the grid is a drop down menu which gives the option to select an item. Once the item is selected the remaining columns will auto populate with price , quantity, amount, etc. Once the amount column populates . I execute a function (OnValueChanged event) to save that row of data with ajax web method. The problem occurs after the first row of data saves. If you immediately move to the second row and select an item sometimes it saves and sometimes it doesn't. If I wait about a minute to select an item in another row it will work but that's not ideal. It always works if I place a breakpoint or an alert in the function. I think it maybe an ajax issue BTW it works perfectly in IE. Would appreciate any help. I've attached a screen shot of the grid and the code.
thanks,
Ron.
I'm using a rad grid to display invoice items. The first column of the grid is a drop down menu which gives the option to select an item. Once the item is selected the remaining columns will auto populate with price , quantity, amount, etc. Once the amount column populates . I execute a function (OnValueChanged event) to save that row of data with ajax web method. The problem occurs after the first row of data saves. If you immediately move to the second row and select an item sometimes it saves and sometimes it doesn't. If I wait about a minute to select an item in another row it will work but that's not ideal. It always works if I place a breakpoint or an alert in the function. I think it maybe an ajax issue BTW it works perfectly in IE. Would appreciate any help. I've attached a screen shot of the grid and the code.
function AmountChanged(sender, args) {
if (args._oldValue != '') {
CalculateGridLineTotals();
ReCalculateTaxes();
}
console.log("Row Number " + rowIndex1)
SaveInvoiceItems();
}
function SaveInvoiceItems() {
var masterTable = $find("<%=grdInvoiceItems.ClientID%>").get_masterTableView();
//for (var row = 0; row < masterTable.get_dataItems().length; row++) {
var Id = masterTable.getCellByColumnUniqueName(masterTable.get_dataItems()[rowIndex1], "Id");
var grid = $find("<%=grdInvoiceItems.ClientID%>");
var masterTbl = grid.get_masterTableView();
var gridRow = masterTbl.get_dataItems()[rowIndex1];
var item = gridRow.findControl("ddlItems")._text;
var description = gridRow.findControl("txtDescription")._text;
var price = gridRow.findControl("txtPrice")._text;
var qty = gridRow.findControl("txtQty")._text;
var discount = gridRow.findControl("txtDiscount")._text;
var amount = gridRow.findControl("lblAmount")._text;
if (discount == '')
discount = 0;
if (price == '')
price = 0;
if (qty == '')
qty = 0;
if (amount == '')
amount = 0;
var obj_as_object = { id: Id.innerHTML, item: item, description: description, price: price, qty: qty, discount: discount, amount: amount };;
var obj_as_string = JSON.stringify(obj_as_object);
var xhr = $.ajax({
type: "POST",
url: "/WebService/InvoiceWebService.asmx/UpdateRecurringInvoiceItems",
data: obj_as_string,
'async': false,
contentType: "application/json; charset=utf-8",
dataType: "json",
beforeSend: function (xhr, settings) {
xhr.startTime = new Date().getTime();
$("#wait").css("display", "block");
},
complete: function (xhr) {
var elapsed = new Date().getTime() - xhr.startTime;
if (elapsed < 3000) {
$("#wait").css("display", "block").delay(7000 - elapsed).hide(1);
} else {
$("#wait").css("display", "block").hide();
}
}
});
//)).then(function (data, textStatus, jqXHR) {
// //alert("what is this"); // Alerts 200
//});
//setTimeout(doSomething(Id.innerHTML), 3000);
//}
}
thanks,
Ron.