Code example: CRMGridColBlock object

This example uses the CRMGridColBlock object to add and remove columns in a list and to edit the properties of columns in a list. The page is used in the Company tab group to show all the People for the current Company.

<!-- #include file ="sagecrm.js" -->
<%

// Start with the Person list.
PersonList = CRM.GetBlock("persongrid");

// Add the Person alternative number as the third column in the list, with no heading.
GridCol = PersonList.AddGridCol("pers_faxnumber",2);
GridCol.ShowHeading = false;

// Get the GridCol block for the FirstName column.
GridCol = PersonList.GetGridCol("pers_firstname");
GridCol.AllowOrderBy = true;
GridCol.ShowHeading = true;

// Set FirstName column to jump to another ASP page.
GridCol.JumpEntity = "custom";
GridCol.CustomActionFile = "myP.asp";
GridCol.CustomIdField = "pers_personId";

// Remove the Company Name column from the list.
PersonList.DeleteGridCol('comp_name');
PersonList.Title = "Standard Person Grid, with some changes";
CompanyId = CRM.GetContextInfo('company','comp_companyid');
CRM.AddContent(PersonList.Execute('pers_companyid = '+CompanyId));
Response.Write(CRM.GetPage());

%>