Friday, 2 August 2013

Attaching Sub Grid Refresh Event In MSCRM 2011



var grid = null;
var gridControl = null;
var ids = null;
var IsScottsdaleShowdown = false;



// call this finction on form laod
function Form_onload() {

// time out set as the grod will load littile late asynchronously after form laod , so we are waiting 2.5 seconds
    setTimeout("SubGridRefresh();", 2500);
}


// Attach  Sub grid refresh event
function SubGridRefresh() {

     grid = document.getElementById("Events");

     // Chek gris controll loaded or not 
    if (grid.readyState != "complete") {
        // delay one second and try after one second whether grid is loaded or not  
        setTimeout(SubGridRefresh, 1000);
        return;
    }

    if (grid) {
    // Attach  grid refresh event
        grid.attachEvent("onrefresh", CustomLogic);

      //cALLING THE CUSTOM LOGIC WHICH NEED TO BE EXECUTED R SUB GRID REFRESH
        grid.control.add_onRefresh(CustomLogic);

    }

    function CustomLogic() {

// Write the custom Logic which need to be executed in Grid Refresh.
    }