代码可以正常工作,直到调用页面方法为止。 这是麻烦的功能
SetCellValueFromKey = (row, CellName, totalQty);
该函数是另一个js文件
function SetCellValueFromKey(theRow, theKey, setValue) {
theRow.get_cellByColumnKey(theKey).set_value(setValue);
}
这是我的页面方法功能
PageMethods.GetSalesOrderInfo(dteStartDate, dteEndDate, ProductsArray, GetSalesOrderInfoCallSuccess, GetSalesOrderInfoCallFailed);
return false;
这是GetSalesOrderInfoCallSuccess函数
function GetSalesOrderInfoCallSuccess(result) {
var lbActualSales = document.getElementById("<%=lbActualSales.ClientID%>");
var hdnWeekNumOfWeekYear = document.getElementById("<%=hdnWeekNumOfWeekYear.ClientID%>").value;
// Code to handle a Success from 'GetActualSalesInfoCallSuccess'
//if result it not null, parse the data
if (result != null) {
var jsResult = JSON.parse(result);
//clear the Actual Sales list box
var NumRows = lbActualSales.length;
if (NumRows != 0) {
for (var i = NumRows - 1; i >= 0 ; i--) {
//remove the row
lbActualSales.options.remove(i);
}
}
NumRows = jsResult.length;
var optionNum = 0;
if (NumRows > 0) {
for (var i = 0; i < NumRows; i++) {
var dataRow = jsResult[i];
//Add the new data into Actual Sales ListBox
var option = "option" + optionNum;
option = document.createElement("option");
lbActualSales.options.add(option, lbActualSales.options.length);
strRow = [dataRow.SalesOrderId] + "|" + [dataRow.ProductId] + "|" + [dataRow.Quantity] + "|" + [dataRow.Weight] + "|" + [dataRow.UnitPrice] + "|" + [dataRow.TotalPrice] + "|" + [dataRow.ListPrice] + "|" + [dataRow.SalesOrderNum] + "|" + [dataRow.CustomerId] + "|" + [dataRow.DateCreated] + "|" + [dataRow.CustomerName] + "|" + [dataRow.UnitOfSale] + "|" + [dataRow.Product_Name] + "|" + [dataRow.Week] + "|" + [dataRow.OrderType];
option.text = strRow;
option.value = [dataRow.ProductId] + "|" + [dataRow.Week];
optionNum = optionNum + 1;
}
}
var grid = getGrid("<%=wdgSalesForecast.ClientID%>");
var search = "";
var totalQty = 0;
NumRows = lbActualSales.length;
//for each row in grid get the ProductId and the week to search into the listBox
for (var i = 0; i < grid.get_rows().get_length() ; i++) {
var row = grid.get_rows().get_row(i);
var productId = getCellValueFromKey(row, "ProductId");
search = productId;
//loop through the row to change each value for Actual Sales
for (var j = 0; j < row.get_cellCount() ; j++) {
var cell = row.get_cell(j);
var CellName = cell._column._key;
//get the week num and build a string "search"
if (CellName.search("ActAmtWk") > -1) {
var WeekNum = CellName.split("ActAmtWk");
WeekNum = WeekNum.pop();
var weekNumOfYear = parseInt(WeekNum) + parseInt(hdnWeekNumOfWeekYear) - 1;
search = search.concat("|");
search = search.concat(weekNumOfYear);
//loop through the Actual Sales List box and search for the product for the specific week
for (var count = 0; count < NumRows; count++) {
if (search == lbActualSales.options[count].value) {
var splitValues = lbActualSales.options[count].text.split("|");
// Calculate the Qty
totalQty = totalQty + parseInt(splitValues[7]);
}
}
//update the Forecast Grid cell with the New Value
SetCellValueFromKey = (row, CellName, totalQty);
}
//reset my search string and totalQty
search = productId;
totalQty = 0;
}
}
UpdateDemandForecast();
}//end of result test
alert('Data Updated successfully');
}//end of function `
ps。我从同一个js文件调用其他函数,但我没有问题。
答案 0 :(得分:1)
您的代码行是一个赋值语句,这就是它引起您问题的原因:
SetCellValueFromKey = (row, CellName, totalQty);
您已经创建了函数SetCellValueFromKey(theRow, theKey, setValue)
,因此要调用该函数,您应该使用:
SetCellValueFromKey(row, CellName, totalQty);
答案 1 :(得分:1)
尝试给予关注
SetCellValueFromKey(row, CellName, totalQty);
代替
SetCellValueFromKey = (row, CellName, totalQty);