2016-05-03 46 views
0

當我使用PuTTY與我的父親一起編程時,我遇到了子網格數據問題。我們用一個子網格做網格;這會收到JSON和PHP響應。我們在Mozilla的壓制和JavaScript代碼的語法中看到它。是否可以,而不是語法或語義問題?我不知道爲什麼我的jqGrid子網格不顯示數據

嗯,這是my page和我的代碼:

$(document).ready(function() { 
    $("#divFacturas").html("<table><tr><td><table id='grillaFac' name='grillaFac' style=' height=2500px width=100%'></table> <DIV id='pggrillaFac' name='pggrillaFac'></DIV></td></tr></table>"); 
    var usuario = $("#usuario").val(); 
    var clave = $("#clave").val(); 
    creaGrillaFacturas(usuario, clave); 

    function creaGrillaFacturas(usuario, clave) { 
     jQuery("#grillaFac").jqGrid(
     { 
      url:'ajaxFacturas.php?usuario=' + usuario + '&clave=' + clave, 
      datatype: "json", 
      colNames:['Codigo', 'Tipo', 'Fecha/hora Comprobante', 'Comprobante', 'Debito', 'Credito', 'Resumen'], 
      colModel:[ { name:'codigo', index:'codigo', width: 80, sorttype:'int'}, 
         { name:'tipo', index:'tipo'}, 
         { name:'fecha', index:'fecha'}, 
         { name:'numero', index:'numero'}, 
         { name:'debito', index:'debito', align: 'right', formatter:"number", summaryType:'sum' }, 
         { name:'credito', index:'credito', align: 'right', formatter:"number", summaryType:'sum' }, 
         { name:'resumen', index:'resumen', align: 'right'} 
        ], 
      rowNum: 1000, 
      shrinkToFit: true, 
      forceFit:true, 
      loadtext: 'Cargando', 
      //loadonce: true, 
      viewrecords: true, 
      pager: '#pggrilla', 
      altRows: true, 
      sortname: 'codigo', 
      sortorder: "desc", 
      forceFit : true, 
      ignoreCase: true, 
      caption:"Comprobantes encontrados", 
      //jsonReader: { repeatitems : false, id: 'codigo', 
      //subgrid: {root: "rows", repeatitems: false}}, 
      jsonReader: { repeatitems: false, id: 'codigo'}, 
      grouping : true, 
      groupingView : { groupField: ['resumen'], 
          groupSummary: [true], 
          groupColumnShow: [true], 
          groupText: ['<b>Resumen Nro.: {0}</b>'], 
          groupCollapse: false, 
          groupOrder: ['desc']}, 
      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; 
       $("#"+subgrid_id).html("<table id='"+subgrid_table_id+"' class='scroll'></table><div id='"+pager_id+"' class='scroll'></div>"); 
       jQuery("#"+subgrid_table_id).jqGrid({ 
        url:"subgrid.php?q=1162&id="+row_id, 
        dataype:"json", 
        colNames: ['Articulos', 'Descripcion', 'Cantidad', 'Precio unitario'], 
        colModel:[ 
         {name:"articulo", index:"articulo", width:100}, 
         {name:"detalle", index:"detalle", width:100}, 
         {name:"cantidad", index:"cantidad", width:100}, 
         {name:"precio", index:"precio", width:100} 
        ], 
        rowNum:20, 
        viewrecords: true, 
        //pager: pager_id, 
        sortname:'articulo', 
        sortorder:"asc", 
        height: '100%' 
       }); 
       //jQuery("#"+subgrid_table_id).jqGrid('navGrid',"#"+pager_id,{edit:false,add:false,del:false}) 
      } 
     }); 

     jQuery("#grillaFac").jqGrid('hideCol', ['codigo']); 
     jQuery("#grillaFac").jqGrid('navGrid', 'pggrillaFac', 
       {search:true, edit:false, add:false, del:false}); 

     $("#grillaFac").setGridWidth($(window).width()-50); 
     $("#grillaFac").setGridHeight($(window).height()-50); 
    } 
}); 

我希望你能幫助我:d。

+0

您的意思是SSH客戶端PuTTY,意味着您正在SSH遠程計算機上工作,或者您指的是其他內容? –

+0

SSH客戶端PuTTY是的,我用它來編輯我認爲服務器.. – tzanuttini

+1

是的,你可能用它來連接到服務器,你在那裏做的工作......好吧,我只是想知道是否有可能是JS庫叫膩子什麼的。嗯,我想知道的另外一件事是,當你寫'depuring'時,你的意思是再寫一個字。如果是這樣的話? –

回答

1

代碼中最重要的錯誤是輸入錯誤:您使用dataype:"json"而不是datatype:"json"作爲子網格的選項。未知選項dataype將被忽略,將使用選項datatype的默認值"xml"。服務器返回JSON數據,jqGrid將嘗試將數據解析爲XML數據。

我建議你不要使用jqGrid的復古版本。您目前使用jqGrid 4.4.1,這是4歲。它相當於駕駛40歲的汽車。我建議你使用免費的jqGrid 4.13.2並直接從CDN加載它。您只需將URL修改爲jqGrid文件即可在the wiki article中描述的URL。

此外,將idPrefix選項添加到子網格並使用某些值的唯一值作爲前綴將很重要。例如,您可以使用idPrefix: "s_" + row_id + "_"idPrefix: subgrid_id或僅使用idPrefix: $.jgrid.randId()。在articulo列中添加key: true似乎也不錯。

+0

Thx so much,we have to change the version of the jqGrid並添加字符。你節省了我月薪:D – tzanuttini

+0

@tzanuttini:不客氣!我很高興能幫助你。我建議你添加Font Awesome併爲jqGrid添加'iconSet:「fontAwesome」'選項來改善網格的外觀。請參閱初步文檔和[wiki文章](https://github.com/free-jqgrid)中的[示例](http://free-jqgrid.github.io/getting-started/index.html#type_of_data_code) /的jqGrid /維基)。在免費的jqGrid中實現的許多其他新功能在每個發佈版本和wiki中的自述文件中都有描述。 – Oleg

相關問題