Hook for adding columns to grids via plugin

Hi there,

currently we have to override initFeatures of grid handlers to provide additional columns via a feature.#But this is only feasible when adding a new grid that news a separate handler.

I want to add columns via plugins so I added a hook in GridHandler::initFeatures()

protected function initFeatures($request, $args) {
$returner = array();
HookRegistry::call(strtolower_codesafe(get_class($this) . '::initFeatures'), array($this, $request, $args, &$returner));
return $returner;

Plugins can now register to that call and add columns via a grid feature as needed, for example:

HookRegistry::register('customformelementsgridhandler::initfeatures', array($this, 'customFormElementsGridHandlerInitFeatures'));

public function customFormElementsGridHandlerInitFeatures($hookName, $args)
	$returner =& $args[3];


	$returner[] = new CustomFormElementIdColumnGridFeature();

class CustomFormElementIdColumnGridFeature extends GridFeature {

	function __construct() {

	// Hooks implementation.
	 * @see GridFeature::gridInitialize()
	function gridInitialize($args) {
		$grid = $args['grid'];

		$grid->addColumn(new CustomFormElementIdGridColumn());


Can we integrate these changes into the official GitHub repo? Should i create an issue and provide a pull request?

So lonG

bump to get a response

Hi @j1shin,

In terms of broader infrastructure, we’re gradually moving away from the grids toolset into a new framework using vue.js; can you describe what part of the code you’re working with, e.g. what grid you’re augmenting?

Alec Smecher
Public Knowledge Project Team

Hi @asmecher,

we have extended the review form with a calculated item to fill in a field automatically based on other field values. This means that the admin needs to enter a fomula to define the calculation. We use the review form item ID in the formulas to refer to a review form item, hence the user needs to see the review form item ID somewhere. So we extended the review form item grid with the code shown in the first post to show
a ID for each form item but this will only work with the aforementioned additional hook.

So lonG

Hi @j1shin,

That sounds sensible to me. Please go ahead and open a PR, linking back here for consistency.

Alec Smecher
Public Knowledge Project Team

Ok, will do, Hook for adding columns to grids via plugin · Issue #4328 · pkp/pkp-lib · GitHub