Hi,
I have resolve my problem, it was simply a wrong column name in sort in sql (php file).
The php file return good when not use with grid but there is wrong parameter sidx when use with grid and return wrong json (empty). I hope can help somebody …
the json
|
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 |
{ "rows": [ { "id": "7", "cell": [ "7", "2017-03-23 00:00:00", "Erreur", "Impossible d'identifier la source du fichier" ] }, { "id": "9", "cell": [ "9", "2017-03-23 00:00:00", "Erreur", "Impossible d'identifier la source du fichier" ] } ], "page": 1, "total": 1, "records": "2" } |
sorry i cant put my code good
|
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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
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&eacute;s" }); |
… 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 |
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('<table id=' + childGridID + '></table><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 }); } |
Copyright 2014 TriRand LtdAll Rights ReservedRSS
Back to Top