我可以在哪里自定义编辑表单或在子网格中添加表单? 如果我想从网格自定义编辑表单我做:
$.extend($.jgrid.edit, {
recreateForm: true,
onInitializeForm: function($form) {
//CHANGE ASPECT IN EDIT FORM
$('<tr class="FormData"><td class="CaptionTD ui-widget-content" colspan="6">' +
'<div style="padding:3px" class="ui-widget-header ui-corner-all">' +
'<b>INFORMATIONS GENERALES</b></div></td></tr>')
.insertBefore('#tr_pers_genre_id');
}
但是子网格在哪里?
这里是网格和子网格代码的一部分
dbbxll.jqGrid({
url: "db_bxll_jqgrid.php?q=2",
editurl: "db_bxll_data.php",
datatype: "xml",
mtype: "GET",
pager: "#pagerdbbxll",
//autowidth: true,
width: 1200,
height: 600,
rowNum: 25,
rowList: [25, 75, 250],
sortname: "pers_date_inscription",
sortorder: "desc",
forceFit: true,
shrinkToFit:true,
viewrecords: true,
gridview: true,
autoencode: true,
toppager: true,
idPrefix: "m",
caption: "db be",
//GROUPING EXAMPLE
grouping:false,
groupingView : {
groupField : ['pers_genre_id'],
groupColumnShow : [true],
groupText : ['<b>{0}</b>'],
// AFFICHE LE NBRE DE LIGNES DANS CHAQUE GROUPE groupText : ['<b>{0} - {1} Item(s)</b>'],
groupCollapse : true,
groupOrder: ['asc']
},
// PRINCIPAL GRID COLUMN DEFINITION
colNames: ["ID","DATE INSCR","DATE REACT","PROVENANCE","GENRE","NUM INSCR","NOM","PRENOM","DATE NAISS","NATIONALITE","NUM IDNATIONAL","NUM IBIS","ADRESSE","N°","BTE","CP","VILLE","GSM","TEL","MAIL","TYPE PERMIS","ETUDE","LIEU ETUDE","DATE INOCC","INOCC","STATUT","CPRO1","CPRO2","CPRO3"],
colModel: [
....
],// end colModel principal grid
subGrid : 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;
var subgrid_table_id9, pager_id9;
subgrid_table_id9 = subgrid_id+"_t9";
pager_id9 = "p9_"+subgrid_table_id9;
// CUT THE idPrefix
var mainGridPrefix = $(this).jqGrid("getGridParam", "idPrefix");
pureRowId = $.jgrid.stripPref(mainGridPrefix, row_id);
$("#"+subgrid_id).html("<table id='"+subgrid_table_id+"' class='scroll'></table><div id='"+pager_id+"' class='scroll'></div><table id='"+subgrid_table_id9+"' class='scroll'></table><div id='"+pager_id9+"' class='scroll'></div>");
// SUIVIS - ENTRETIEN SUBGRID DETAIL
jQuery("#"+subgrid_table_id).jqGrid({
hiddengrid:true,
width: 1100,
height: 300,
url:"entretien_subgrid.php?q=2&id="+pureRowId,
datatype: "xml",
mtype: 'GET',
pager: '#entretienpagerdetail',
rowNum:50,
rowList:[5,10,20,30,40,50],
rownumbers: true,
viewrecords: true,
pager: pager_id,
idPrefix: "s" + row_id + "_",
caption:"SUIVIS",
ondblClickRow: function (rowid, iRow, iCol, e) {e.stopPropagation();},
colNames:['ENT_ID','ID','DATE ENTRETIEN','PROJET','CONSEILLER','COMMENTAIRE'],
colModel:[
],
subGrid: true,
subGridRowExpanded: function (subgrid_id2, row_id2) {
// SUBGRID ACTIONS
var subgrid_table_id2, pager_id2;
subgrid_table_id2 = subgrid_id2+"_t2";
pager_id2 = "p2_"+subgrid_table_id2;
// SUBGRID ER
var subgrid_table_id3, pager_id3;
subgrid_table_id3 = subgrid_id2+"_t3";
pager_id3 = "p2_"+subgrid_table_id3;
// SUBGRID RESULTAT
var subgrid_table_id4, pager_id4;
subgrid_table_id4 = subgrid_id2+"_t4";
pager_id4 = "p2_"+subgrid_table_id4;
// CUT IDPREFIX
var mainGridPrefix = $(this).jqGrid("getGridParam", "idPrefix");
pureRowId2 = $.jgrid.stripPref(mainGridPrefix, row_id2);
$("#"+subgrid_id2).html("<table id='"+subgrid_table_id2+"' class='scroll'></table><div id='"+pager_id2+"' class='scroll'></div><table id='"+subgrid_table_id3+"' class='scroll'></table><div id='"+pager_id3+"' class='scroll'></div><table id='"+subgrid_table_id4+"' class='scroll'></table><div id='"+pager_id4+"' class='scroll'></div>");
//SUBGRID ACTIONS I've 3 subrids I show completely one
jQuery("#"+subgrid_table_id2).jqGrid({
...
}); // END SUBGRID ACTION
...
//SUBGRID RESULTAT
jQuery("#"+subgrid_table_id4).jqGrid({
hiddengrid: true,
width: 1000,
height: 150,
url:"resultat_subgrid.php?q=3&ent_id="+pureRowId2,
datatype: "xml",
mtype: 'GET',
pager: '#resultatpagerdetail',
rowNum:50,
rowList:[5,10,20,30,40,50],
rownumbers: true,
viewrecords: true,
pager: pager_id4,
caption:"RESULTATS",
ondblClickRow: function (rowid, iRow, iCol, e) {e.stopPropagation();},
colNames:['RES_ID','DATE RESULTAT','RESULTAT','COMMENTAIRE','ENT_ID'],
colModel:[
...
],
}); // END SUBGRID
// NAVGRID RESULTAT
jQuery("#"+subgrid_table_id4).jqGrid('navGrid',"#"+pager_id4,{edit:true,add:true,del:true},
{//prmEdit
//reloadAfterSubmit:false,
closeAfterEdit:true,
bSubmit: "Modifier",
width:400,
onclickSubmit: function(fordid) {
var mygrid = $("#"+subgrid_table_id4);
var did = mygrid.jqGrid('getGridParam','selrow');
var celdid = mygrid.jqGrid('getCell', did, 'res_id');
if (did != null) {
jQuery("#"+subgrid_table_id4).setGridParam({editurl:'resultat_updatedel.php?q=3&res_id='+celdid});
//alert(celdid);
}
else alert("Vous n'avez sélectionné aucun projet")
},
//refresh:true
},//end edit
{//prmAdd
closeAfterAdd:true,
bSubmit: "Sauvegarder",
width:400,
//reloadAfterSubmit:true,
beforeShowForm: function(formid) {
// we should get the id of the first subgrid here : subgrid_table_id
var mid = jQuery("#"+subgrid_table_id).getGridParam('selrow');
pureRowId = $.jgrid.stripPref(mainGridPrefix, mid);
if (mid != null ) {
// now we can set it in addurl
jQuery("#"+subgrid_table_id4).setGridParam({editurl:'resultat_add.php?q=3&ent_id=0'+pureRowId});
}
else alert("Vous n'avez sélectionné aucun projet")
}
},//end add
{//prmDel
closeAfterDel:true,
//reloadAfterSubmit:false,
onclickSubmit: function(fordid) {
var mygrid = $("#"+subgrid_table_id4);
var did = mygrid.jqGrid('getGridParam','selrow');
var celdid = mygrid.jqGrid('getCell', did, 'res_id');
if (did != null) {
jQuery("#"+subgrid_table_id4).setGridParam({editurl:'resultat_updatedel.php?q=3&res_id='+celdid});
//alert(celdid);
}
else alert("Vous n'avez sélectionné aucun projet")
},
}//end del
);//end navgrid resultat
}, // end subgridrowexpanded
嗯,文件太长了,但我可以把它完全放好。 谢谢所有