Sometimes we have requirements to attach click event to sub-grid. So we could read selected record data and do the stuffs.
Here is sample code to attach click event to sub grid :
function ReadSelectedSubGridRecords() {
if (document.getElementById("SubGridName")) {
var grid = document.getElementById("SubGridName").control;
for (var rowNo = 0; rowNo < grid.get_selectedRecords().length; rowNo++)
alert(grid.get_selectedRecords()[rowNo].Name);
}
}
function Form_OnLoad() {
if (document.getElementById("SubGridName")) {
var grid = document.getElementById("SubGridName");
// Google chrome
if (grid.addEventListener) {
grid.addEventListener('click', ReadSelectedSubGridRecords, false);
// IE
} else if (grid.attachEvent) {
grid.attachEvent('onclick', ReadSelectedSubGridRecords);
}
}
else {
setTimeout("Form_OnLoad();", 2000);
}
}
For more information please follow this BLOG
No comments:
Post a Comment