私は自分のグリッドで少し奇妙な問題を抱えており、その理由がわかりません。私はいくつかのサブグリッドを作成しましたが、このグリッドで問題が発生したことはありませんが、出産は困難です。メイン グリッドの情報は問題なく表示されますが、サブグリッドには何も表示されません。
つまり、php json をサブグリッドに提供することにも成功しました。別のサブグリッドが機能する必要があり、URL、フィールドなどを変更していましたが、メイングリッドの URL を変更した場合にのみ、表示できるようになりました。なぜ誰かが知っているのですか?
jQuery("#organismos").jqGrid({
url: 'model/ministerio/mod_organismo.php',
colNames:['Cód. Organismo','Data Efetiva','Estado', 'Sigla', 'Designação curta', 'Designação longa', 'Última alteração', 'Alterado pelo utilizador'],
colModel:[
{name:'COD_ORG',index:'COD_ORG',width:80, align:'center', editable:true, editrules:{required:true}, editoptions:{size: 5 ,maxlength:4}, formoptions: { elmsuffix: ' *'}},
{name:'DATA_EFETIVA',index:'DATA_EFETIVA',width:100,align:'center',datefmt: 'Y/M/d', editrules:{date:true},editable:true,editoptions:{ size: 11, maxlength: 10,dataInit: function(element) {$(element).datepicker({dateFormat: date_format, autosize:true})}}, formoptions: { elmsuffix: ' *'}},
{name:'ESTADO_DTEF',index:'ESTADO_DTEF',width:50, align:'center',edittype:'select', editoptions:{value:{A:'Ativo',I:'Inativo'}}, editable:true, editrules:{required:true}, formoptions: { elmsuffix: ' *'}},
{name:'SIGLA_ORG',index:'SIGLA_ORG',width:80, align:'center', editable:true, editrules:{required:true}, editoptions:{size: 13 ,maxlength:12}, formoptions: { elmsuffix: ' *'}},
{name:'DESC_C_ORG',index:'DESC_C_ORG', width:150, align:'center', editable:true, editoptions:{size: 31, maxlength:30}},
{name:'DESC_L_ORG',index:'DESC_L_ORG', width:300, align:'center', edittype:'textarea' ,editable:true, editrules:{required:true}, editoptions:{size: 31, maxlength:150}, formoptions: { elmsuffix: ' *'}},
{name:'DATA_ULT_ALT',index:'DATA_ULT_ALT', hidden:true},
{name:'UTILIZADOR',index:'UTILIZADOR', hidden:true}
],
sortname: 'DATA_EFETIVA',
caption:"Objetivo do Projeto",
pager: '#pager1',
height:'400',
multiselect: false,
subGrid: true,
subGridOptions: { "plusicon" : "ui-icon-triangle-1-e",
"minusicon" :"ui-icon-triangle-1-s",
"openicon" : "ui-icon-arrowreturn-1-e",
"reloadOnExpand" : false,
"selectOnExpand" : true },
subGridRowExpanded: function(subgrid_id, row_id) {
var subgrid_table_id, pager_id;
subgrid_table_id = subgrid_id+"_t";
pager_id = "p_"+subgrid_table_id;
$("#"+subgrid_id).html("<table id='"+subgrid_table_id+"' class='scroll'></table><div id='"+pager_id+"' class='scroll'></div>");
jQuery("#"+subgrid_table_id).jqGrid({
url:"model/objetivos/mod_obj_estrategicos.php?idorg="+row_id,
colNames:['Cód. Obj. Estratégico','Data Efetiva','Estado', 'Designação curta', 'Designação longa', 'Peso', 'Última alteração', 'Alterado pelo utilizador'],
colModel:[
{name:'COD_OBJ_EST',index:'COD_OBJ_EST', width:80, align:'center', editable:true, editrules:{required:true}, editoptions:{size: 5 ,maxlength:4}, formoptions: { elmsuffix: ' *'}},
{name:'DATA_EFETIVA',index:'DATA_EFETIVA',width:100,align:'center',editable:true,editoptions:{ size: 11, maxlength: 10,dataInit: function(element) {$(element).datepicker({dateFormat: date_format, autosize:true})}}, formoptions: { elmsuffix: ' *'}},
{name:'ESTADO_DTEF',index:'ESTADO_DTEF', width:50, align:'center',edittype:'select', editoptions:{value:{A:'Ativo',I:'Inativo'}}, editable:true, editrules:{required:true}, formoptions: { elmsuffix: ' *'}},
{name:'DESC_C_OBJ_EST',index:'DESC_C_OBJ_EST', width:100, align:'center' ,editable:true, editrules:{required:true}, editoptions:{size: 31 ,maxlength:30}, formoptions: { elmsuffix: ' *'}},
{name:'DESC_L_OBJ_EST',index:'DESC_L_OBJ_EST', width:300, align:'center', edittype:'textarea' ,editable:true, editrules:{required:true}, editoptions:{size: 31 ,maxlength:150}, formoptions: { elmsuffix: ' *'}},
{name:'PESO',index:'PESO', width:50, align:'center',editable:true, editrules:{required:true, number: true}, editoptions:{size: 6 ,maxlength:5}, formoptions: { elmsuffix: ' *'}},
{name:'DATA_ULT_ALT',index:'DATA_ULT_ALT', hidden:true},
{name:'UTILIZADOR',index:'UTILIZADOR', hidden:true}
],
rowNum:20,
pager: pager_id,
sortorder: "asc",
editurl:"controller/objetivos/Estrategicos.php?idorg=" +row_id,
height: '100%',
autowidth: true
});
jQuery("#"+subgrid_table_id).jqGrid('navGrid',"#"+pager_id,{edit:true,add:true,del:true, view:true});
}
});
グリッド 1 からの JSON の結果:
{"page":"1","total":1,"records":"3","rows":[{"id":"1 ","cell":["1 ","2012\/10\/24","Ativo","Ta","funcionar?","OK","2012\/10\/18 13:49:35","1"]},{"id":"21 ","cell":["21 ","2012\/10\/31","Ativo","aa","aaa","oaa","2013\/01\/17 10:59:52","1"]},{"id":"12 ","cell":["12 ","2013\/01\/09","Ativo","TEJO","rio","rio","2013\/01\/03 18:21:40","1"]}]}
グリッド 1 で行を選択すると、グリッド 2 から JSON が生成されます。
{"page":"1","total":1,"records":"3","rows":[{"id":"AAASwaAAEAAAAC7AAA","cell":["12 ","2013\/01\/03","Ativo","1","1","1","2013\/01\/18 15:00:46","1"]},{"id":"AAASwaAAEAAAAC\/AAA","cell":["3 ","2012\/11\/01","Ativo","Barcelona","Juventus","14.9","2012\/12\/28 14:49:57","1"]},{"id":"AAASwaAAEAAAAC8AAB","cell":["4 ","2012\/12\/24","Ativo","Sim","ok","75.69","2012\/12\/28 14:50:33","1"]}]}