Building List screens with FilterBoxes

2 minute read time.
 Custom Pages that contain Search screens are fussy about block positioning.
The search block does not work correctly if it is included into the container following the list making it more difficult to create a screen with filterbox like behaviour. The type of Screen I am aiming at is shown here. This is a known issue.

The problem can be illustrated with some example code. For instance, the following code works:


var FilterBoxBlock = CRM.GetBlock("projectfilterbox");
var ProjectListBlock = CRM.GetBlock("ProjectList");
var myBlockContainer = CRM.GetBlock("Container");
with (myBlockContainer)
{
AddBlock(FilterBoxBlock);
AddBlock(ProjectListBlock);
}
ProjectListBlock.ArgObj = FilterBoxBlock;



BUT!!!!!

This code sample does not:


var FilterBoxBlock = CRM.GetBlock("projectfilterbox");
FilterBoxBlock.NewLine = false;
var ProjectListBlock = CRM.GetBlock("ProjectList");
var myBlockContainer = CRM.GetBlock("Container");
with (myBlockContainer)
{
AddBlock(ProjectListBlock);
AddBlock(FilterBoxBlock);
}
ProjectListBlock.ArgObj = FilterBoxBlock;


All that is different is that I have moved the search block to the right hand side of the List block.

To work round this I have had to control the building of the Argument that is passed to the list block. The following code is a partial work around for this issue.
You will still have to do some fine tuning but it should give you an idea.

The code is designed to be added to the Company tab group and call a list of projects belonging to that company.


if (CRM.Mode == View)
{
CRM.Mode = Edit;
}

var intRecordId = CRM.GetContextInfo("company","comp_companyid");
var strFilterButton = CRM.Button("filter", "filter.gif", "javascript:document.EntryForm.submit();");

var projectlistBlock = CRM.GetBlock("projectlist");

var FilterBoxBlock = CRM.GetBlock("projectfilterbox");
with (FilterBoxBlock)
{
NewLine = false;
AddButton(strFilterButton);
ButtonLocation = Bottom;
ButtonAlignment = Right;
}

var SuperContainer = CRM.GetBlock("Container");
with (SuperContainer)
{
AddBlock(projectlistBlock);
AddBlock(FilterBoxBlock);
DisplayButton(Button_Default) = false;
}

//Make sure fields in filter box are each on new line.
var strArg="proj_companyid="+intRecordId;
var myE = new Enumerator(FilterBoxBlock);
while (!myE.atEnd())
{
myEntryBlock = myE.item();
if (String(Request.Form(myE.item()))!='undefined')
{
strArg+=" and "+myE.item()+" like '"+Request.Form(myE.item())+"%'";
}
myEntryBlock.NewLine = true;
myEntryBlock.AllowBlank = false;
myE.moveNext();
}

projectlistBlock.ArgObj = strArg;

CRM.AddContent(SuperContainer.Execute());
Response.Write(CRM.GetPage());


Parents
No Data
Comment
  • $core_v2_ui.GetResizedImageHtml($comment.User.AvatarUrl, 44, 44, "%{border='0px', alt=$comment.User.DisplayName, ResizeMethod='ZoomAndCrop'}")
    $core_v2_ui.UserPresence($comment.User.Id) $comment.User.DisplayName
    This comment is under review.
Children
No Data