locked
JScript to Disable subgrid rows in mscrm 2011

    Question

  • Hi,

    I used script to disable Subgrid in my form. The grid looks read-only but if i click any record in subgrid, i was navigated to that entity. Is there any way to disable the grid row navigation?

    Monday, November 26, 2012 8:32 AM

All replies

  • Hi,

    As far as I know you only have one possibility: in your onload-event of the form you have to overlay the subgrid-HTML-element with a new div-element which prevent the mouse to call a onclick-event in the subgrid...

    Best regards,

    Andreas


    Andreas Buchinger
    Microsoft Dynamics Certified Technology Specialist
    MCPD: SharePoint Developer 2010

    Monday, November 26, 2012 9:01 AM
  • Hi,

    If you requirement is to just show those records and prevent them from opening check the below link. It can be a work around using IFrame.

    http://guruprasadcrm.blogspot.in/2011/12/display-fetchxml-in-iframe-in-crm-2011.html

    Hope this helps.

    Thanks,

    Prasad

    Monday, November 26, 2012 6:09 PM
  • I have used the following code for disabling where in form, the record appears to be read-only but i am able to access the records if i double click. Please provide me the code which prevents on click of the subgrid records

    disableSubgridHyperlinkColumns =

    function() {

    var subgridArea = document.getElementById("Contact_divDataArea");

    if (subgridArea != null) {

    var subgridTable = subgridArea.childNodes[0].childNodes[0];

    for (i = 1; i < subgridTable.rows.length; i++) {

    for (j = 2; j < subgridTable.rows[i].cells.length; j++) {

    if (subgridTable.rows[i].cells[j].childNodes[0].childNodes[0] != null && subgridTable.rows[i].cells[j].childNodes[0].childNodes[0].nodeName == "A") {

    subgridTable.rows[i].cells[j].childNodes[0].childNodes[0].outerHTML = subgridTable.rows[i].cells[j].childNodes[0].childNodes[0].innerText;

    }

    }

    }

    }

    }

    function

    disableSubgrid(subgridName) {

    var _subGrid = document.getElementById(subgridName + "_span");

    if (_subGrid) {

    _subGrid.disabled =

    "true";

    }

    }

    Thursday, November 29, 2012 3:15 PM
  • Hi,

    I've used this code to set a overlay on an iframe FROM inside of the iframe (HTML-site):

    function SetWaitingCursor()
            {
                if ($("#fwi-overlay-box", window.top.document.body).length == 0)
                {
                    var overlay = "<div class='fwi-overlay' style='; top: 0px: left: 0px; height: 100%; width: 100%;opacity: 0.7; filter: alpha(opacity = 80); z-index: 100000;background: url(/_imgs/AdvFind/progress.gif) no-repeat center center #FFF;" +
                    "text-align: center'><p style='; top: 52%; left: 50%;margin-left: -105px; font: 20px bolder; font-family: Segoe UI, Tahoma, Arial'>Speichervorgang läuft...</p></div>";
                    var overlayContainer = document.createElement("div");
                    overlayContainer.id = "fwi-overlay-box";
                    overlayContainer.style.position = "fixed";
                    overlayContainer.style.top = "0px";
                    overlayContainer.style.left = "0px";
                    overlayContainer.style.height = "100%";
                    overlayContainer.style.width = "100%";
                    overlayContainer.style.zIndex = "10000";
    
                    $(overlayContainer).append(overlay);
                    window.top.document.body.appendChild(overlayContainer);                
                }
            }
            function SetNormalCursor()
            {
                $("#fwi-overlay-box", window.top.document.body).fadeOut(1000, function ()
                {
                    $(this).remove();
                });
            }

    Depends on wether you call the functions you must adapt the references...

    br,

    Andreas


    Andreas Buchinger
    Microsoft Dynamics Certified Technology Specialist
    MCPD: SharePoint Developer 2010

    Thursday, November 29, 2012 4:15 PM
  • hi

    check with below code

    function enableDisableSubGrid(subGridName, boolFlag){
     var _subGrid = document.getElementById(subGridName + "_span");
     _subGrid.disabled = boolFlag;
    }
    
    //just call it by passing the subgrid name and the bool //flag
    //true: it will disable the sub grid
    //flase: it will enable the subgrid


    Please don't forget to Vote and marked as answer If this post answers your question or was helpful, please click "Mark As Answer" on the post and "Mark as Helpful" Be wise

    Friday, November 30, 2012 3:21 AM
  • Hi SHRIV,

    Anwars  code will disable the subgrid means ,subgrid records will grayed out. But if you click on link or double click on the record present in subgrid they will open.

    i Think you can try out with this.

    function attachSubGridRefresh()
    {
        var grid = document.getElementById("subgrid_test");
        if (grid)
    	{
            grid.attachEvent("onrefresh", disableSubgridHyperlinkColumns);
        }
    }
    
    disableSubgridHyperlinkColumns = function()
    {
    	var subgridArea = document.getElementById("subgrid_test");
    	if (subgridArea != null)
    	{
    		var subgridTable = subgridArea.childNodes[0].childNodes[0];
    		for(i = 1; i < subgridTable.rows.length; i++)
    		{
    			for(j = 2; j < subgridTable.rows[i].cells.length; j++)
    			{
    				if (subgridTable.rows[i].cells[j].childNodes[0].childNodes[0] != null && subgridTable.rows[i].cells[j].childNodes[0].childNodes[0].nodeName == "A")
    				{
    					subgridTable.rows[i].cells[j].childNodes[0].childNodes[0].outerHTML = subgridTable.rows[i].cells[j].childNodes[0].childNodes[0].innerText;
    				}
    			}
    		}
    	}
    }

    Hope it helps.

    Regards

    irpathan

    Friday, November 30, 2012 9:29 AM
  • Hi,

    You can Disable Subgrid using HTML Overlay.

    Your Subgrid element with name "subgrid1".

    You use following Function to disable Subgrid:-

    function disablegrid(){

    document.getElementById("subgrid1_d").innerHTML = "<img style='; z-index:5000' src='/_imgs/imagestrips/transparent_spacer.gif' height='100%' width='100%'/>" + document.getElementById("subgrid1_d").innerHTML;

    }

    its 100% working.

    If your problem solved Then mark it as answer.

    Regards.


    Friday, December 21, 2012 5:07 PM
  • Thank you sir its really great help, i'm searching for this solution for last month and tody i got the answer. Thank you very much.
    Friday, December 21, 2012 5:56 PM