Saturday, June 11, 2011

Tab Properties Using JavaScript in MS CRM 2011

In this post I will show you some of the properties of the tab control. The JavaScript code is listed in List 1. Here you can see that I have set the name of the function loopThroughAllTab which you can call from anywhere. In the function I have used the Xrm.Page.ui.tabs.get() function which will return all the tabs on the page and I have store the list in the tabList. The getName will return the name of the tab control like general, details etc on the account entity. and the getLabel will return the label which is shown on the account entity like General, Details etc.Some times you need to compare the name or the display name to search for specific tab control.

List 1

The getDisplayState return expanded or collapsed value, depending on the setting of the tab control on the tab property dialog. It also has the counter set function which will be used to set the DisplayState of the tab control. And Last function is the getVisible which return either true or false depending on the visibility of the tab control.
Image 1
In Image 1 I have shown what function will return what on the tab properties dialog.

All and any comments / bugs / suggestions are welcomed !

1 comment:

pathankhan said...

I need the all tabs to be expanded or collpsed at a time, i need the count of all tabs and done in one loop.

eg :

function Form_Onload()
{
for(var i=0;i<5;i++)
{
Xrm.Page.ui.tabs.get(i).setDisplayState("expanded");
}
}

In i<5 i need to keep the number of tabs, it may increase or decrease later but code does not change.

send an mail to firoze.pathan.khan@gmail.com