This example shows how to completely override the common editing process.
Data will be updated in two separate tables with signle ajax-request.

It also validates the book name in PHP.
Try to enter very short 'Book name' to see it in action. Just throw an exception anywhere to stop the script execution and display error to user.
Этот пример показывает, как можно полностью заменить стандартную операцию редактирования.
Данные берутся из двух разных таблиц и обновляются сразу в двух таблицах одновременно.

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


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

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

class jqOperBasic extends jqGrid
{
    protected function init()
    {
        $this->table = 'tbl_order_item';

        $this->query = "
			SELECT {fields}
			FROM tbl_order_item i
				JOIN tbl_books b ON (i.book_id=b.id)
			WHERE {where}
		";

        #Set columns
        $this->cols = array(

            'item_id' => array('label' => 'ID',
                'db' => 'i.id',
                'width' => 10,
                'align' => 'center',
                'formatter' => 'integer',
            ),

            'order_id' => array('label' => 'Order id',
                'db' => 'i.order_id',
                'width' => 15,
                'align' => 'center',
                'formatter' => 'integer',
            ),

            'name' => array('label' => 'Book name',
                'db' => 'b.name',
                'width' => 30,
                'editable' => true,
                'editrules' => array('required' => true),
            ),

            'price' => array('label' => 'Price',
                'db' => 'i.price',
                'width' => 15,
                'align' => 'center',
                'formatter' => 'integer',
                'editable' => true,
                'editrules' => array('required' => true,
                    'integer' => true,
                    'minValue' => 1,
                    'maxValue' => 3000
                ),
            ),
        );

        #Set nav
        $this->nav = array('edit' => true, 'edittext' => 'Edit');
    }

    #Save columns to different tables
    protected function opEdit($id, $upd)
    {
        #Server-side validation
        if(strlen($upd['name']) < 5)
        {
            #Just throw the exception anywhere inside the oper functions to stop execution and display error
            throw new jqGrid_Exception('The book name is too short!');
        }

        #Get editing row
        $result = $this->DB->query('SELECT * FROM tbl_order_item WHERE id=' . intval($id));
        $row = $this->DB->fetch($result);

        #Save book name to books table
        $this->DB->update('tbl_books', array('name' => $upd['name']), array('id' => $row['book_id']));
        unset($upd['name']);

        #Save other vars to items table
        $this->DB->update('tbl_order_item', $upd, array('id' => $id));
    }
}
<script>
    <?= $rendered_grid ?>
</script>