php数组里面的jqGrid colModel参数

时间:2016-11-01 16:24:53

标签: php jquery arrays json jqgrid

我正在使用最新版本中使用jqGrid的项目。 问题是这个项目是PHP(5.6)并且使用JSON来“翻译/交谈”到jqGrid框架,而colModel参数都在PHP数组中。 它完美无缺,但我无法使用实际项目的代码触发colModel“criacao”的dataInit。 感谢你的时间!

public function laudos($section)
    {
        $table = 'laudos';
        $fields = array('id','laudo','nome_fantasia','cliente','cadastro_id','email','senha','exame','descricao','criacao','exclusao','arquivo');
        $tabela = array(
            'colNames' => array('ID','Laudo','Clínica','Nome','Cadastro','Email','Senha','Exame','Descrição','Criação','Exclusão','Arquivo'),
            'colModel' => array(
                array('name'=>'id','hidden'=>true,'search'=>true,'key'=>true),
                array('name'=>'laudo','index'=>'laudo','width'=>70,'align'=>'center','search'=>true,'editable'=>true,'editrules'=>array('required'=>true),'sorttype'=>'integer','searchoptions'=>array('sopt'=>'[eq,cn]', 'clearSearch'=>false)),
                array('name'=>'nome_fantasia','search'=>true,'width'=>170,'align'=>'center','editable'=>false,'sorttype'=>'text','searchoptions'=>array('sopt'=>'[eq,cn]','clearSearch'=>false),'editrules'=>array('required'=>true)),
                array('name'=>'cliente','search'=>true,'width'=>170,'align'=>'center','editable'=>false,'sorttype'=>'text','searchoptions'=>array('sopt'=>'[eq,cn]','clearSearch'=>false),'editrules'=>array('required'=>true),),
                array('name'=>'cadastro_id','search'=>true,'hidden'=>true,
                    'editable'=>true,'edittype'=>'text','searchoptions'=>array('sopt'=>'[eq,cn]','clearSearch'=>false),'editrules'=>array('edithidden'=>true,'required'=>true),
                    'editoptions'=>array('dataInit'=>'[]')),
                array('name'=>'email','search'=>true,'hidden'=>true,'editable'=>true,'sorttype'=>'email','searchoptions'=>array('sopt'=>'[eq,cn]','clearSearch'=>false),'editrules'=>array('edithidden'=>true)),
                array('name'=>'senha','search'=>true,'hidden'=>true,'editable'=>true,'editrules'=>array('edithidden'=>true)),
                array('name'=>'exame','search'=>true,'width'=>50,'align'=>'center','editable'=>true,'sorttype'=>'text','searchoptions'=>array('sopt'=>'[eq,cn]','clearSearch'=>false),'formatter'=>'select','edittype'=>'select',
                    'editoptions'=>array('value'=>array('Biópsia'=>'Biópsia','Necrópsia'=>'Necrópsia','Citologia'=>'Citologia'))
                ),
                array('name'=>'descricao','search'=>true,'width'=>200,'align'=>'center','editable'=>true,'sorttype'=>'text','searchoptions'=>array('sopt'=>'[eq,cn]','clearSearch'=>false)),
                array('name'=>'criacao','search'=>true,'width'=>70,'formatter'=>'date','fixed'=>true,'resizable'=>false,'align'=>'center','sorttype'=>'date','searchoptions'=>array('sopt'=>'[eq,cn]','clearSearch'=>false), 'editoptions'=>array('dataInit'=>'function (elem) { $(elem).datepicker();')),
                array('name'=>'exclusao','search'=>true,'width'=>70,'formatter'=>'date','sorttype'=>'date','fixed'=>true,'resizable'=>false,'editable'=>true,'searchoptions'=>array('sopt'=>'[eq,cn]','clearSearch'=>false),'align'=>'center'),
                array('name'=>'arquivo','search'=>false,'width'=>60,'formatter'=>'arquivo','classes'=>'tabela_laudo_arquivo','editable'=>true,'searchoptions'=>array('sopt'=>false,'clearSearch'=>false))
            ),
            'sortname' => 'id',
            'caption' => 'Registros de Laudos Cadastrados',
            );

更新 使用jQGrid $ .extend,可以使用php和基本java脚本设置co​​lModel属性以及所有jQGrid设置,属性和事件。

示例:

var p = $("#tabela-laudos").jqGrid("getGridParam");
        //=================================================
        p.colModel[p.iColByName.laudo] = $.extend(true,
            {},
            p.colModel[p.iColByName.laudo], //NEW VALUES BELOW
            {
                editoptions:
                {
                    placeholder: "Ex.: 17777"
                },
            }
        );

1 个答案:

答案 0 :(得分:0)

使用jQGrid $ .extend,即使在加载初始设置后,也可以设置colModel的colModel属性设置,属性和事件。

示例:

var p = $("#tabela-laudos").jqGrid("getGridParam");
        //=================================================
        p.colModel[p.iColByName.laudo] = $.extend(true,
            {},
            p.colModel[p.iColByName.laudo], //NEW VALUES BELOW
            {
                editoptions:
                {
                    placeholder: "Ex.: 17777"
                },
            }
        );