Tuesday, November 24, 2015

Update Grid Fetch in client side


Here is my example to update grid request in Client Site.

create new function and check if grid is already loaded

function UpdateGridOptions() {

    var myGrid = document.getElementById("myGridExample");

   
    if (myGrid == null || myGrid .readyState != "complete") {
     
        setTimeout('UpdateGridOptions()', 1000);
        return;
    }
    if (Xrm.Page.getAttribute('accountid').getValue() != null) {
        var accountId = Xrm.Page.getAttribute('accountid').getValue()[0].id;
        var fetchXml = GetFetchForGrid(accountId, Xrm.Page.data.entity.getId());
        //update grid with new fetchXml
        myGrid .control.SetParameter("fetchXml", fetchXml);
        //Refresh grid
        myGrid .control.refresh();

    }
}
Enjoy,
Rami Heleg

No comments:

Post a Comment