Case study. Layout designer: creating your own renderer for a Grid cell

Creating your own renderer is quite easy. There are two ways:

  • a cell renderer based on the dictionary key (displaying the value) - for DVelum 0/8/9 and higher;
  • your own renderer.

To add your own renderer to the Layout Designer, it is necessary and sufficient to declare its class.

Create a folder for the project renderers:

www/system/library/Ext/Component/Renderer/Myproject

Create the following file: www/system/library/Ext/Component/Renderer/Myproject/Status.php

(for example use the task dictionary, which describes the statuses of the background task)


class Ext_Component_Renderer_Myproject_Status extends Ext_Component_Abstract_Renderer_Dictionary
{
 /*
  * Dictionary name 
  */
 protected $_name = 'task';
}

The renderer for a dictionary value is ready.

Create your own renderer:


class Ext_Component_Renderer_Myproject_Custom extends Ext_Component_Renderer{
    public function __toString() 
    {
        return 'function(value, metaData, record, rowIndex, colIndex, store){return "Custom renderer " + value;}';
    }
}

Also, you can return the function name:

class Ext_Component_Renderer_Myproject_Custom extends Ext_Component_Renderer{
    public function __toString()
    { 
        return 'app.creatorRenderer';
    }
}