[英]I don't know why my jqGrid subgrid doesn't show me the data
I have problem with my subgrid data when I use PuTTY to program with my father. 当我使用PuTTY与父亲编程时,我的子网格数据有问题。 We do a grid with a subgrid; 我们使用子网格进行网格处理; this receives JSON and PHP responses. 这将接收JSON和PHP响应。 We see it in the depuring of Mozilla and the syntax of the JavaScript code. 我们在对Mozilla的反感和JavaScript代码的语法中看到了这一点。 Is it OK, not a problem of syntax or semantics? 可以,不是语法或语义问题吗?
Well, this is my page and my code: 好吧,这是我的页面和我的代码:
$(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);
}
});
I hope you can help me :D. 我希望你能帮助我:D。
The most important bug in your code is the typing error: you use dataype:"json"
instead of datatype:"json"
as the option of subgrid. 代码中最重要的错误是键入错误:您使用dataype:"json"
而不是datatype:"json"
作为dataype:"json"
的选项。 The unknown option dataype
will be ignored and the default value "xml"
of the option datatype
will be used. 未知选项dataype
将被忽略,默认值为"xml"
选项的datatype
将被使用。 The server returns JSON data and jqGrid will try to parse the data as XML data. 服务器返回JSON数据,jqGrid将尝试将数据解析为XML数据。
I recommend you don't use retro versions of jqGrid. 我建议您不要使用jqGrid的复古版本。 You use currently jqGrid 4.4.1, which is 4 years old. 您当前使用的是4年以前的jqGrid 4.4.1。 It corresponds driving the auto which is 40 years old. 它对应于驾驶已有40年历史的汽车。 I recommend you to use free jqGrid 4.13.2 and load it directly from the CDN. 我建议您使用免费的jqGrid 4.13.2并直接从CDN加载它。 You need just modify the URLs to jqGrid files to URLs described in the wiki article . 您只需将jqGrid文件的URL修改为Wiki文章中描述的 URL。
Additionally it would be important to add idPrefix
option to subgrid and use some unique value as the prefix. 另外,将idPrefix
选项添加到子网格并使用一些唯一值作为前缀也很重要。 For example you can use idPrefix: "s_" + row_id + "_"
or idPrefix: subgrid_id
or just idPrefix: $.jgrid.randId()
. 例如,您可以使用idPrefix: "s_" + row_id + "_"
或idPrefix: subgrid_id
或仅idPrefix: $.jgrid.randId()
。 Adding of key: true
in the articulo
column seems be good too. 添加key: true
在articulo
列中为key: true
似乎也不错。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.