hi,
i use a grid as subgrid, the main grid use datatype: “json” with php and works good.
But the subgrid use json too and not work (empty) even if i use the same url and the same parameter.
In the php i use :
header(‘Content-type: application/json;charset=utf-8′);
…
echo json_encode($response);
if i use php url in chrome and copy the json result and put it in a file .json then i change subgrid url to call .json file it work like in main grid
I have try in xml and i have the exactly same effect !!! good if i use .xml with copy of xml generated and not good if i use php file to create xml (with xml header)
my code
[code]
var mygrid = jQuery("#filesLst").jqGrid({
url:’../api/fichiers/lstFiles.php’,
datatype: "json",
colNames:[‘id’, ‘date trait.’, ‘Source’,’Etat’, ‘Nom’, ‘Evenement’, ‘Message’],
colModel:[
{name:’id’,index:’idFichier’, width:80,
searchoptions:{
sopt:[‘eq’,’ne’,’lt’,’le’,’gt’,’ge’],
clearSearch:false
},
searchrules:{
integer:true
}
},
{name:’dateTraitement’,index:’datePECFichier’, width:90, formatter:’date’,
formatoptions:{
srcformat: ‘ISO8601Long’,
newformat: ‘d-m-Y’,
defaultValue:null
},
searchoptions:{
dataInit:function(el){
$(el).datepicker({dateFormat:’dd-mm-yy’});
},
sopt:[‘ge’,’gt’,’eq’,’ne’,’lt’,’le’],
defaultValue:’<!–?php echo date("d-m-Y", strtotime("-1 year", strtotime(date("d-m-Y"))));?–>’,
clearSearch:false
},
searchrules:{
date:true
}
},
{name:’source’,index:’libelleSource’, width:90,
stype:"select",
searchoptions:{
dataUrl:"../api/sources/selectSource.php",
sopt:[‘eq’,’ne’],
clearSearch:false
}
},
{name:’etat’,index:’libelleEtat’, width:90,
stype:"select",
searchoptions:{
dataUrl:"../api/etats/selectEtat.php",
sopt:[‘eq’,’ne’],
clearSearch:false
}
},
{name:’nom’,index:’nomFichier’, width:350,
searchoptions:{
sopt:[‘eq’,’ne’,’bw’,’bn’,’in’,’ni’,’ew’,’en’,’cn’,’nc’],
clearSearch:false
}
},
{name:’evenement’,index:’evenementFichier’, width:350,
searchoptions:{
sopt:[‘eq’,’ne’,’bw’,’bn’,’in’,’ni’,’ew’,’en’,’cn’,’nc’],
clearSearch:false
}
},
{name:’message’,index:’messageFichier’, width:350,
searchoptions:{
sopt:[‘eq’,’ne’,’bw’,’bn’,’in’,’ni’,’ew’,’en’,’cn’,’nc’],
clearSearch:false
}
}
],
rowNum:15,
rowList:[15,30,60],
pager: ‘#filesListBut’,
sortname: ‘idFichier’,
viewrecords: true,
sortorder: "desc",
autowidth: true,
height: ‘350px’,
subGrid : true,
subGridRowExpanded: showChildGrid,
caption:"Liste des fichiers d’interface traités"
});
[/code]
… other code to nav, filter search and title …
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
[code]</code> function showChildGrid(parentRowID, parentRowKey) { //alert('http://localhost/xdemat-siig/api/traitements/lstTraitements.php?id=' + parentRowKey); // create unique table and pager var childGridID = parentRowID + "_table"; var childGridPagerID = parentRowID + "_pager"; // add a table and pager HTML elements to the parent grid row - we will render the child grid here $('#' + parentRowID).append(' &lt;table id=" + childGridID + "&gt;&lt;/table&gt; <div></div> '); $("#" + childGridID).jqGrid({ url: '../api/traitements/lstTraitements.php?id=' + parentRowKey, mtype: "GET", datatype: "json", colNames:['idTrait', 'DeteTraite', 'EtatTrait', 'MessageTrait'], colModel: [ { name : 'idTrait' , index : 'idTrait' , width: 25, key: true }, { name : 'DeteTraite' , index : 'DeteTraite' , width: 100 }, { name : 'EtatTrait' , index : 'EtatTrait' , width: 100 }, { name : 'MessageTrait' , index : 'MessageTrait' , width: 100 } ], page:1, rows:10, height: '150px', sortname: 'idTrait', sortorder: "desc", pager: "#" + childGridPagerID }); <code>[/code]` thanks you in advance for yours response and help. |
Copyright 2014 TriRand LtdAll Rights ReservedRSS
Back to Top