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
190
Populate Values on the Next Cell Based on Page Method Success function in web Data Grid
posted

Hi, i have Implemenrtted Web Data Grid and on One Value , Request is sending to the Server , Getting Record Against that Value (this is Working FIne). and Need to populate the Data on Next Cell, which is not Populating.

My Code is :

function KeyDown(sender, eventArgs) {
sender = sender;
rowsCount = sender.get_rows().get_length();
columnsCount = sender.get_columns().get_length();
rowIndex = sender.get_behaviors().get_activation().get_activeCell().get_row().get_index();
fromLastColumn = sender.get_behaviors().get_activation().get_activeCell().get_column().get_index();

var keyCode = eventArgs.get_browserEvent().keyCode;
var newActiveCell;
if (keyCode == 9)
{
var grid = getGridByID('<%=grdDetail1.ClientID%>');
grid.get_behaviors().get_selection().get_selectedRows().add(grid.get_rows().get_row(0));
var a = grid.get_behaviors().get_activation().get_activeCell().get_row().get_cellByColumnKey("tax_number")
var usingRowSelection = a.get_text()
NextColumn = grid.get_behaviors().get_activation().get_activeCell().get_row().get_cellByColumnKey("Name");
console.log("NextColumn In KeyDown" + " " + NextColumn)
GetDetailByTax_NumberOnNextKin(usingRowSelection)

setTimeout(function () {
//alert("hi")
//alert(document.getElementById('hfName').value);
console.log(document.getElementById('hfName').value);
NextColumn.set_value(document.getElementById('hfName').value);
console.log("i am Executed");
}, 1000);

//var rowsCount = sender.get_rows().get_length();
//var columnsCount = sender.get_columns().get_length();
//var rowIndex = sender.get_behaviors().get_activation().get_activeCell().get_row().get_index();
//var fromLastColumn = sender.get_behaviors().get_activation().get_activeCell().get_column().get_index();

//var keyCode = eventArgs.get_browserEvent().keyCode;
//var newActiveCell;
//if (keyCode == 9) {
// if ((rowIndex + 1) === rowsCount) {
// if (fromLastColumn === 0) {
// newActiveCell = sender.get_rows().get_row(rowIndex).get_cell(currentCellColumnIndex);
// } else {
// if ((currentCellColumnIndex + 1) === columnsCount) { //for the last column
// newActiveCell = sender.get_rows().get_row(0).get_cell(0);
// currentCellColumnIndex = 0;
// } else {
// newActiveCell = sender.get_rows().get_row(0).get_cell(++currentCellColumnIndex);
// }
// }
// } else {
// if (fromLastColumn === 0) {
// newActiveCell = sender.get_rows().get_row(rowIndex).get_cell(currentCellColumnIndex);
// } else {
// newActiveCell = sender.get_rows().get_row(rowIndex + 1).get_cell(currentCellColumnIndex);
// }
// }

// sender.get_behaviors().get_activation().set_activeCell(newActiveCell);
//}


}
}

function GetDetailByTax_NumberOnNextKin(obj) {
PageMethods.GetDetailByTax_Number(obj, OnNextKinSuccess);
}

function OnNextKinSuccess(data) {
debugger

if (data != null || data != "") {
var grid = getGridByID('<%=grdDetail1.ClientID%>');

NextColumn.set_value(data);
document.getElementById('hfName').value = data;
//var cell = grid.get_rows().get_row(0).get_cell(1);
//grid.get_behaviors().get_activation().set_activeCell(cell);
// Get active cell
//var activeCell = grid.get_behaviors().get_activation().get_activeCell();

// var cell = grid.get_behaviors().get_activation().get_activeCell().get_row(0);
// grid.get_behaviors().get_activation().set_activeCell(cell);

//if (fromLastColumn === 0) {
// newActiveCell = grid.get_rows().get_row(rowIndex).get_cell(currentCellColumnIndex);
//} else {
// if ((currentCellColumnIndex + 1) === columnsCount) { //for the last column
// newActiveCell = grid.get_rows().get_row(0).get_cell(0);
// currentCellColumnIndex = 0;
// } else {
// newActiveCell = grid.get_rows().get_row(0).get_cell(++currentCellColumnIndex);
// }
//}
} else {
if (fromLastColumn === 0) {
newActiveCell = grid.get_rows().get_row(rowIndex).get_cell(currentCellColumnIndex);
} else {
newActiveCell = grid.get_rows().get_row(rowIndex + 1).get_cell(currentCellColumnIndex);
}
// sender.get_behaviors().get_activation().set_activeCell(newActiveCell);
}


}

  • 1080
    Offline posted

    Hello,

    Thank you for posting in our community.

    Since there are missing pieces like the code-behind and how WebDataGrid is defined, I have created and attached a small sample with cascading WebDropDown in WebDataGrid which demonstrates retrieving of data for the next cell based on the current one.

    Please take a look at it and let me know whether it helps you to achieve your requirement. If this is not an accurate demonstration of what you are trying to achieve please feel free to modify it and send it back to me for further investigation.

    Looking forward to hearing from you.

    5822.Sample.zip