Course Content

Expand All

Grids Custom Options Configurations

In this example we want to define the domain of the possible options of an Options column.

A typical case in which you want to define “manually” the options of a column is the one in which a field, is the Device field of service operations.

In fact, this custom field appears as select in the form and allows you to associate a ticket to a ticket from the Devices class.

When this field is displayed in grid, the CI entity_id will be displayed and not its name.

In order to display its name in grid and use a select filter, it is necessary to properly configure the column.

To achieve this it is necessary to access the grid configuration page and set the column type to ‘Options’ and then insert some PHP code in the ‘Options’ scripting area.

Insert the following code inside the scripting area:

//retreive of the CI collection
$ciCollection = Deep::getResourceModel('deep_cmdb/ci_collection');
//filter in the Clause where of the query to retrieve only Devices class ICs
//convert the collection into an associative array
//the keys is the CI Id and the value the CI Name
$optionsArray = $ciCollection->toOptionHash();
return $optionsArray;

Now the Device column will display the Name of the related CI.

In addition, grid records can be filtered via select or multiselect