Show multiple Panel/Lists on a screen using .NET API

By | June 2, 2012

Screen designing and positioning in dot net API with latest Sage CRM versions has become very much simpler. It provides standard code templates for developer to generate the custom pages on the fly. We came across one common scenario many times wherein people try to display two panels next to each other on same page. So thought to give it a try using API. Here are the findings.
Consider below scenario
I want to display Communication List, Opportunity List and CompanyBoxShort entry group on a single screen. I followed below steps
1)     First I create the object of Communication List, Opportunity List and  CompanyBoxShort Entry Group respectively.
List CommList = new List(“communicationlist”);
CommList.Title = Metadata.GetTranslation(“tabnames”,”communication”);
CommList.Filter = “CmLi_Comm_CompanyId= ” + GetContextInfo(“company”, “comp_companyid”);
List OppoList = new List(“opportunitylist”);
OppoList.Title = Metadata.GetTranslation(“tabnames”, “opportunity”);
OppoList.Filter = “oppo_primarycompanyid =  ” + GetContextInfo(“company”, “comp_companyid”);
EntryGroup CompanyBoxShort = new EntryGroup(“CompanyBoxShort”);
CompanyBoxShort.Title = Metadata.GetTranslation(“tabnames”, “company”);
CompanyBoxShort.AddAttribute(“width”, “100%”);
Record recComp = FindCurrentRecord(“Company”);
CompanyBoxShort.GetHtmlInViewMode(recComp);
2)     Then I took object of Horizontal and Vertical Panel respectively.
HorizontalPanel hpPanel = new HorizontalPanel();
hpPanel.AddAttribute(“width”, “100%”);
hpPanel.Add(CommList);
hpPanel.Add(OppoList);
VerticalPanel vpPanel = new VerticalPanel();
hpPanel.AddAttribute(“width”, “100%”);
vpPanel.Add(CompanyBoxShort);
3)     Now I want to display Horizontal Panel at the TOP of the screen and Vertical Panel at the BOTTOM of the screen. For that I called AddContent() method for Horizontal Panel Object first and then for Vertical Panel Object.
AddContent(hpPanel);
AddContent(vpPanel);
4)     Now if you want to do vice-versa then call AddContent() method for Vertical Panel Object first and then for Horizontal Panel Object like below.
AddContent(vpPanel);
AddContent(hpPanel);
Here is the complete code snippet for your reference.
public override void BuildContents()
{
 GetTabs();
 List CommList = new List(“communicationlist”);
 CommList.Title = Metadata.GetTranslation(“tabnames”, “communication”);
 CommList.Filter = “CmLi_Comm_CompanyId= ” + GetContextInfo(“company”, “comp_companyid”);
 List OppoList = new List(“opportunitylist”);
 OppoList.Title = Metadata.GetTranslation(“tabnames”, “opportunity”);
 OppoList.Filter = “oppo_primarycompanyid = ” + GetContextInfo(“company”, “comp_companyid”);
 EntryGroup CompanyBoxShort = new EntryGroup(“CompanyBoxShort”);
 CompanyBoxShort.Title = Metadata.GetTranslation(“tabnames”, “company”);
 CompanyBoxShort.AddAttribute(“width”, “100%”);
 Record recComp = FindCurrentRecord(“Company”);
 CompanyBoxShort.GetHtmlInViewMode(recComp);
 HorizontalPanel hpPanel = new HorizontalPanel();
 hpPanel.AddAttribute(“width”, “100%”);
 hpPanel.Add(CommList);
 hpPanel.Add(OppoList);
 VerticalPanel vpPanel = new VerticalPanel();
 hpPanel.AddAttribute(“width”, “100%”);
 vpPanel.Add(CompanyBoxShort);
 AddContent(vpPanel);
 AddContent(hpPanel);
 }