Further to Ian Urquhart's excellent idea of wrapping the filter box + button(s) in html to make it resemble the output in standard CRM pages, and then add the code as a button (that was inspired!), the following code sample generates list + filter box screens that are compatible with the 'Contemporary' AND the older (and far better in my opinion) 'Classical' CRM themes:
CurrentCompanyID=CRM.GetContextInfo("company", "Comp_CompanyId");
var sURL=new String( Request.ServerVariables("URL")() + "?" + Request.QueryString );
// Get the list block
List=CRM.GetBlock("CompanyEntityGrid");
List.prevURL=sURL;
// Get the filter screen block and configure it
FilterBox=CRM.GetBlock("CompanyEntityFilterBox");
FilterBox.NewLine = false;
FilterBox.DisplayForm = false;
FilterBox.DisplayButton(Button_Default) = false;
FilterBox.ButtonLocation=Bottom;
FilterBox.ShowValidationErrors = false;
FilterBox.RefreshFromContent = true;
// Get the container, add list and set it's ArgObj to the filter box
container = CRM.GetBlock('container');
container.DisplayButton(Button_Default) = false;
container.AddBlock(List);
List.ArgObj = FilterBox;
// Compile the filter screen + buttons html
fbHtml = "<table class="ButtonGroup"><tbody><tr><td class="FilterButtonItem">";
fbHtml += FilterBox.Execute();
fbHtml += CRM.Button("filter", "filter.gif", "javascript:document.EntryForm.submit();").replace("</td><td>","</td><td width="32" class="FilterIconClass">").replace("er_buttonItem ","FilterButtonItem "); //note the terminal spaces in the params in the 2nd replace!
fbHtml += "</td></tr><tr><td class="ButtonItem">";
fbHtml += CRM.Button("New", "new.gif", CRM.URL("Entity/EntityNew.asp")+"&E=Entity", 'Entity', 'insert');
fbHtml += "</td></tr></tbody></table><table>";
// Add the compiled html to the list block as a button
List.AddButton(fbHtml);
// Code generated by the entity wizard:
if( false )
{
container.WorkflowTable = 'Entity';
container.ShowNewWorkflowButtons = true;
}
if( CurrentCompanyID != null && CurrentCompanyID != '' )
{
CRM.AddContent(container.Execute("Enty_CompanyId="+CurrentCompanyID));
}
else
{
CRM.AddContent(container.Execute("Enty_CompanyId IS NULL"));
}
Response.Write(CRM.GetPage('Company'));
Note that it isn't necessary to do a dummy container.Execute().</table>