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


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

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

class jqPrimaryId extends jqGrid
{
    protected function init()
    {
        #Set table
        $this->table = 'tbl_customer';

        #Set columns
        $this->cols = array(
            'id' => array(
                'label' => 'ID',
                'width' => 10,
                'align' => 'center',
                'editable' => true,
            ),

            'first_name' => array(
                'label' => 'First name',
                'width' => 35,
                'editable' => true,
                'editrules' => array('required' => true),
            ),

            'last_name' => array(
                'label' => 'Last name',
                'width' => 35,
                'editable' => true,
                'editrules' => array('required' => true),
            ),

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

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

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

        #Set nav
        $this->nav = array('add' => true, 'edit' => true, 'del' => true);
    }
}
<script>
    <?= $rendered_grid ?>
</script>