0

I try to get subgrid control to set it's unvisible. Here my code

function OnReady(){
   var subgrid = document.getElementById("documents_subgrid");
   if (subgrid == null) {
       setTimeout(OnReady(), 1000);
       return;
   }
}

This code works onLoad. It worked in CRM2011, but don't work in CRM2013

Please, help

ernikoss
  • 63
  • 1
  • 2
  • 9

2 Answers2

0

Is better if you get the control, and use the .setVisible("false"). On 2013 the html of the control changed that's probably why that js is not working since you were getting the id of a div that probably is not there anymore. Be careful there are some problems with how the subgrid is getting loaded.

Mauro De Biasio
  • 1,146
  • 6
  • 16
  • If I get document.getElementById("documents_subgrid").control there is error "Unable to get property control or undefined or null referenced", cause I can't get element from page – ernikoss Apr 04 '14 at 06:11
  • Hi ernikoss, get the control i mean use Xrm.Page.ui.controls, get all of them fine the one with the correct name and you should be able to hide/show it. My suggestion is to not work directly with a subgrid (that can be very annoying), but to modify the form, add a section, put the subgrid in the section and work with that: Xrm.Page.ui.tabs.get("yourtabname").sections.get("your section name").setVisible(false); – Mauro De Biasio Apr 07 '14 at 00:20
0

I found solution

var timer = setInterval(function () { GetSubgrid(); }, 1000);
function GetSubgrid() {
    var div = document.getElementById("temp_subgrid");
    if (div != null) {
        clearInterval(timer);            
    }
}

Set timer as onload event.

ernikoss
  • 63
  • 1
  • 2
  • 9