我正在对我的控制器进行ajax调用,数据将在该网格中显示,其中包含一个寻呼机。这是我的网格声明。
function BuildApportGrid() {
jQuery("#grid_apport").jqGrid('GridUnload');
jQuery("#grid_apport").jqGrid({
editurl: "clientArray",
datatype: "json",
data: [],
colNames: ['Code Barrage', 'Organisation', 'Nom', 'Date', 'Cote à 8h', 'Volume total', 'Debit', 'Apport', 'Volume restitue'],
colModel: [{
name: 'code',
index: 'code',
hidden: true,
search: false,
editable: true
}, {
name: 'organisation',
index: 'organisation',
hidden: true,
search: false,
editable: true
}, {
name: 'nom',
index: 'nom',
hidden: false,
search: false,
editable: true
}, {
name: 'date',
width: 100,
index: 'date',
hidden: false,
search: false,
editable: true
}, {
name: 'cote_a_8h',
width: 100,
index: 'cote_a_8h',
hidden: false,
search: false,
editable: true
}, {
name: 'volume_total',
width: 100,
index: 'volume_total',
hidden: false,
search: false,
editable: true
}, {
name: 'debit',
width: 100,
index: 'debit',
hidden: false,
search: false,
editable: true
}, {
name: 'apport',
width: 100,
index: 'apport',
hidden: false,
search: false,
editable: true
}, {
name: 'volume_restitue',
width: 100,
index: 'volume_restitue',
hidden: false,
search: false,
editable: true
}
],
onSelectRow: function (rowid) {},
ondblClickRow: function (rowid) {},
onCellSelect: function (rowid, iCol, cellcontent, e) { },
sortorder: "desc",
viewrecords: false,
pager: '#pager_grid_apport'
});
jQuery("#grid_apport").jqGrid('navGrid', '#pager_grid_apport', {
edit: false,
add: false,
del: false,
search: false,
refresh: false
}).navButtonAdd('#pager_grid_apport', {
caption: "",
buttonicon: "ui-icon-excel",
title: "Exporter vers excel",
onClickButton: function () {},
position: "last"
}).navButtonAdd('#pager_grid_apport', {
caption: "",
buttonicon: "ui-icon-linechart",
title: "Verifier les bornes sur la carte",
onClickButton: function () {},
position: "last"
});
html部分如下所示:
<div class="content_div" style="margin-left:5px">
<table id="grid_apport"></table><div id="pager_grid_apport"></div>
ajax调用如下:
$.ajax({
type: "POST",
url: '/xxx_web/Prelevement/getGridData',
dataType: "json",
data: {
date_debut: dijit.byId('start_date_apport').get("value"),
date_fin: dijit.byId('end_date_apport').get("value"),
selxml: viewerFrame.mapFrame.GetSelectionXML()
},
success: function (data) {
jQuery("#grid_apport").jqGrid("clearGridData");//erreur
jQuery("#grid_apport").jqGrid('setGridParam', {
datatype: 'local',
data: data
}).trigger("reloadGrid");
}
});
错误显示为:TypeError:b.jgrid.formatter未定义。 当我对此行进行注释时,网格工作但在重新加载数据时不会清除数据。我错过了什么?!谢谢你的时间。 这是针对网格的这个奇怪错误的更多细节:
我错过了什么?!
编辑:
数据是json格式,这是json构造:
var jsonData =
(from item in data select new {
code = item[1] == null ? "" : item[1].ToString(),
organisation = item[2] == null ? "" : item[2].ToString(),
nom = item[3] == null ? "" : item[3].ToString(),
date = item[4] == null ? "" : String.Format("{0:dd/MM/yyyy}", item[4]),
cote_a_8h = item[5] == null ? "" : item[5].ToString(),
volume_total = item[6] == null ? "" : item[6].ToString(),
debit = item[7] == null ? "" : item[7].ToString(),
apport = item[8] == null ? "" : item[8].ToString(),
volume_restitue = item[9] == null ? "" : item[9].ToString()
}).ToList();