我有一个子网格,当您单击“奶酪”旁边的“+”号时,ajax 查询会触发,我会看到子网格列名,但实际数据并未填充到子网格中。无论我尝试扩展哪个网格,都会出现问题,但“奶酪”示例如下所示。
您可以在屏幕截图的 FireBug 输出的底部看到 XML 响应。我已经通读了那个 XML,它看起来是有效的。凭直觉,我还把 XML 输出粘贴到了这个页面中,而且缩进看起来还不错。最重要的是,我还让 ajax 调用返回了一些非常基本的值,无论我到目前为止尝试了什么,网格仍然是空的。
您应该在子网格中看到的是:
------------------------------------------------------
|Translations | Language | Active |
------------------------------------------------------
| It's cheesy goodness | EN | No |
| fromage | FR | No |
| | DE | N/A | <-- "N/A" means there's no translation of "cheese" in German, currently in the database
... etc., with all supported languages listed.
子网格的代码是:
$("#translationsList").jqGrid({
caption : "Translations",
datatype : "xml",
url : translationsFeed,
editurl : translationsEdit,
mtype : "get",
pager : "#translationsPager",
rowNum : 20,
autowidth : true,
sortname : "phrase",
sortorder : "asc",
viewrecords : true,
multiselect : false,
hidegrid : false,
height : 300,
altRows : true,
rownumbers : true,
toolbar : [false],
colNames : ["phrase_id", "translation_id", "language_cd", "Phrase", "Translation", "Created", "Modified", "Active"],
colModel : [
{ name : "phrase_id", index : "phrase_id", sortable : true, search : false, editable : true, edittype : "text", editrules: { edithidden :true }, hidden : true},
{ name : "translation_id", index : "translation_id", sortable : false, search : false, editable : true, edittype : "text", editrules: { edithidden :true }, hidden : true},
{ name : "language_cd", index : "language_cd", sortable : true, search : true, editable : true, edittype : "text", editrules: { edithidden: true, required : true }, hidden : true },
{ name : "Phrase", width:200, index : "phrase", sortable : true, search : true, editable : true, edittype : "text", editrules: { required : true } },
{ name : "Translation", width:200, index : "translation", sortable : true, search : true, editable : true, edittype : "text", editrules: { required : false } },
{ name : "Created", width:100, index : "modify_dt", sortable : true, search : true },
{ name : "Modified", width:100, index : "create_dt", sortable : true, search : true },
{ name : "Active", width:20, index : "active", sortable : true, search : true, editable : true, edittype : "select", editoptions:{value:"0:No;1:Yes"} }
],
onSelectRow: function(id) {
jQuery('#translationsList').editRow(id, true);
},
subGrid: true,
subGridUrl: 'ajax/translations_subgrid_feed.php',
subgridtype: 'xml',
subGridModel : [{
name : ['Translations', 'Language', 'Active'],
width : [583, 70, 80],
align : ['left','right','right'],
params : ['phrase_id']
}],
subGridOptions: {
plusicon : "ui-icon-plus",
minusicon : "ui-icon-minus",
openicon: "ui-icon-carat-1-sw",
expandOnLoad: true,
selectOnExpand : false,
reloadOnExpand : true
}
});
主/子网格的 XML 响应可以在这个 Gist中找到