Monday, June 4, 2012

how to disable the Sub-Grid in MS CRM 2011 (unsupported)

Sometimes we need the subgrid to be disabled in the form, just to show the records.
here i will show it, but its not supported(i mean not available in sdk).
Also its not 100% disabled, as you can select the record and open it. but you will not get the ribbon also the scroll bar will not come it the window is not sufficient to fit the grid.

i will put the snaps before and after the sub grid is disabled.

1. image before the sub grid is disabled

 2. So you will get the ribbon related to the sub grid (entity)
 3. after the grid is disabled
 4. but still you can select the record and open, but not corresponding ribbon for that, as you can not select the subgrid :P

So how it works...

just pass the subgrid name and the boolean value true/false to the below function.

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

in the SDK, the setDisabled() function does not support for the webresources and subgrids controls under Xrm.Page.ui.

am flagging such work around UNSUPPORTED , else ppl will shout at it :P

regards,
Sudhanshu

3 comments:

  1. thanks a lot for this code! but, even the subgrid was already disabled, the user can still open the record after double clicking it. can you suggest any fix on this?

    ReplyDelete
  2. How do you accomplish this in Chrome? seems like it's still editable. But it does work in Outlook and IE.

    ReplyDelete
  3. How to disable the records in the subgrid

    ReplyDelete