Sorry for the long description but it's the only way I can explain this.
I'm currently working on a RadGrid with 5 columns. On page load if there are existing rows for an invoice, they are loaded into the grid, if there are none then it creates a new one ready for batch editing. When the user fills in the Code cell and tabs to the next which is Description, I make a webmethod call to the database to get the corresponding description and want to will that into the next column. This is all working, until I add multiple rows. For some reason the indexes retrieve the rows in inverse order. For example if I create the first row, fill in Code, hit tab, Description is populated from the database. If I create another row, fill in Code, hit tab, Description in the first row updated, not two. If I change the Code in row one again, Description in row two is updated. This holds up for any number of added rows. If there are any existing rows from the database, this does not happen. I can update Code and Description is updated correctly. When I try to add new rows to a table with existing loaded from the database, the crazy index logic starts again.
Here is the javascript I am using to make the cell changes. This is called on RadGrid2_OnBatchEditCellValueChanged:
If I can provide any extra explanation or code please let me know. Any help on this issue would be much appreciated.
Nick
I'm currently working on a RadGrid with 5 columns. On page load if there are existing rows for an invoice, they are loaded into the grid, if there are none then it creates a new one ready for batch editing. When the user fills in the Code cell and tabs to the next which is Description, I make a webmethod call to the database to get the corresponding description and want to will that into the next column. This is all working, until I add multiple rows. For some reason the indexes retrieve the rows in inverse order. For example if I create the first row, fill in Code, hit tab, Description is populated from the database. If I create another row, fill in Code, hit tab, Description in the first row updated, not two. If I change the Code in row one again, Description in row two is updated. This holds up for any number of added rows. If there are any existing rows from the database, this does not happen. I can update Code and Description is updated correctly. When I try to add new rows to a table with existing loaded from the database, the crazy index logic starts again.
Here is the javascript I am using to make the cell changes. This is called on RadGrid2_OnBatchEditCellValueChanged:
function
getDescription(sender, args) {
var
grid = $find(
'<%= RadGrid2.ClientID %>'
);
var
masterTable = grid.get_masterTableView();
var
rows = masterTable.get_dataItems();
var
rowArgs = args.get_row();
var
rowIndex = rowArgs.sectionRowIndex;
var
row = rows[rowIndex];
var
newValue = args.get_editorValue();
var
lineDescCell = row.get_cell(
"Description"
);
var
lineDesc = sender.get_batchEditingManager().getCellValue(lineDescCell);
$.ajax({
type:
"POST"
,
url:
"Invoice.aspx/LookupCode"
,
data: JSON.stringify({ code: newValue }),
contentType:
"application/json; charset=utf-8"
,
dataType:
"json"
,
success:
function
(msg) {
lineDesc = (!msg || !msg.d) ?
"Invalid Code"
: msg.d;
grid.get_batchEditingManager().changeCellValue(lineDescCell, lineDesc);
},
error:
function
(response) {
alert(
'LookupCode failed: '
+ response);
}
});
}
If I can provide any extra explanation or code please let me know. Any help on this issue would be much appreciated.
Nick