php数组内的jqGrid colModel参数

问题描述:

我正在使用一个在最新版本中使用jqGrid的项目. 事实是,该项目是PHP(5.6),并使用JSON转换/对话"到jqGrid框架,而colModel参数都在PHP数组内. 它可以正常工作,但我无法使用实际项目的代码触发colModel"criacao"的dataInit. 感谢您的宝贵时间!

I'm working with a project that uses jqGrid in the most recent version. The thing is that this project is PHP(5.6) and uses JSON to "translate/talk" to jqGrid framework, and colModel parameters are all inside PHP arrays. It works flawlessly but i'm unable to trigger dataInit of colModel "criacao" using the actual project's code. Thx for your time!

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和具有所有jQGrid设置,属性和事件的基本Java脚本来设置colModel属性.

UPDATE: Using jQGrid $.extend, it was possible to set colModel attributes using php and a base java script with all jQGrid settings, properties and events.

示例:

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"
                },
            }
        );

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

Using jQGrid $.extend, it is possible to set colModel attributes settings, properties and events of colModel's even after inital settings loaded.

示例:

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"
                },
            }
        );