You can set grid options in a numerous ways. Each step is merging with the previous one.

The order is the following:

1. (JS) Altering $.jqgrid.defaults
2. (PHP) Setting property $this->options
3. (PHP) Overloading function renderOptions
4. (JS) Creating object, passed as 2nd argument to 'render' method

It is highly recommended to use JS ways. This is the most natural approach.
But if you need to generate some settings dynamically in PHP - you welcome.

Please click some rows and the "Select all" checkbox to see JS events are in place.
Вы можете указывать настройки таблицы несколькими способами.

1. (JS) Изменяя $.jqgrid.defaults
2. (PHP) Изменяя массив $this->options
3. (PHP) Перегружая фукнцию renderOptions
4. (JS) Передавая объект с настройками вторым аргументом в функцию render.

Каждый следующий метод перезаписывает настройки, которые были указаны ранее.

В большинстве случаев рекомендуется использовать javascript.
Если вам необходимо динамически генерировать определенные настройки в PHP - используйте серверные методы.

Покликайте на ряды таблицы, а также на галочку "Выделить все".
higrid.net嗨网提供电子表格、在线图形等互联网开发及运营技术,提供相关资料及软件下载,分享奇趣网络时事评论!欢迎访问。


部分内容为俄文,higrid计划翻译一下。敬请期待!

php代码和js代码请点击tab查看。
<?php

class jqRender1 extends jqGrid
{
    protected function init()
    {
        #Grid options in PHP init
        $this->options = array(
            'multiselect' => true,
            'multiboxonly' => true,

            #JS function in PHP are possible, but not recommended!
            'onSelectRow' => new jqGrid_Data_Raw("function(id){ alert('Row '+id+' selected'); }"),
        );

        $this->table = 'tbl_customer';

        $this->cols = array(

            'id' => array('label' => 'ID',
                'width' => 10,
                'align' => 'center',
            ),

            'first_name' => array('label' => 'First name',
                'width' => 35,
            ),

            'last_name' => array('label' => 'Last name',
                'width' => 35,
            ),

            'email' => array('label' => 'Email',
                'width' => 30,
            ),

            'phone' => array('label' => 'Phone',
                'width' => 25,
                'align' => 'center',
            ),

            'discount' => array('label' => 'Discount',
                'width' => 15,
                'formatter' => 'numeric',
                'align' => 'center',
            ),
        );

        $this->render_filter_toolbar = true;
    }

    #Final options hook. Called on rendering only!
    protected function renderOptions($opts)
    {
        $opts['caption'] = 'Members on ' . date('d.m.Y');

        return $opts;
    }
}
<script>
    //JS functions in JS code - recommended way
    var opts = {
        onSelectAll:function () {
            alert("All rows selected!");
        }
    };

    <?= $rendered_grid ?>
</script>