Is it possible to class method instead of function to event

I usually use

function my_beforeRend($dataItem){
$grid->event->attach('beforeRender', 'my_beforeRend');

My situation is below:

class MyClass{
  function my_beforeRender($dataItem){
  function disp(){
    $grid->event->attach('beforeRender','MyClass.mybeforeRender'); // how to set 2nd parameter

Thanks in advance.

It is the same format as used by call_user_func

call_user_func(array($classname, ‘say_hello’));
call_user_func($classname .’::say_hello’); // As of 5.2.3

//prior PHP 5.23
$grid->event->attach('beforeRender',array('MyClass', 'mybeforeRender'));
//PHP 5.2.3 and later

It works now.
Thanks Stanislav.

Can I pass one more or more arguments than the default individual $dataItem into the method?

Nope, you can’t change that.
If you are using a method of the class, you can store some extra value as property of a class object. So code will be able to access it from the event handler.

I also hope to store properties in the class object but failed. It seems that the DhxGrid attached the method ahead of the PageGrid# object creation, so it only can use the static variables.
In my situation, I hope the following php code:

abstract class absClass{
protected $id;
public function __construct($id){
public function id(){
return $this->id;
public function display(){
$grid = new \GridConnector($this->conn(),‘MySQLi’);
abstract public function my_beforeRender(\GridDataItem $dataItem);

class PageGrid1 extends absClass{
public function my_beforeRender(\GridDataItem $dataitem){
$imgpath = path($this->id()); ///// NOTICE: I cannot access $this->id() because id is not initialized.

Above code does not work, so I now changed to the following which I’m not intended to:

abstract class absClass{
// the same as above definition, except for changing my_beforeRender to static
abstract static function my_beforeRender(\GridDataItem $dataitem);
class PageGrid1 extends absClass{
static $idd=1;
public function __construct(){
public function my_beforeRender(\GridDataItem $dataitem){
$imgpath = path(self::$idd); //

Try to change


to the


Change first parameter from name of class to the class instance.

It’s so great.
Thanks Stanislav!