当我在 aspx 页面中尝试相同的代码时,我试图将 json 格式数据绑定到 jqgrid,它不会引发任何错误,但在 cshtml 页面页面中,它会抛出 jqgrid 不是函数的错误。我无法看到网格的设计。我的代码是这样的
<script language="javascript" type="text/javascript">
$(document).ready(function () {
var gridimgpath = 'themes/basic/images';
$("#projectList").jqGrid({
datatype: "json",
height: 150,
colNames: ['WorkSpaceName', 'Id'],
colModel: [
{ name: 'Id', index: 'Id', width: 600 },
{ name: 'WorkSpaceName', index: 'WorkSpaceName', width: 600 },
],
imgpath: gridimgpath,
multiselect: true,
ignoreCase: true,
hidegrid: false,
caption: "WorkSpace Name",
pager: '#gridpager',
rowNum: 10,
viewrecords: true,
rowList: [10, 20, 30, 40]
});
$.ajax({
url: 'OauthVerifierNew',
type: 'GET',
dataType: "json",
contentType: 'application/json; charset=utf-8',
data: {},
beforeSend: function () {
alert("hello")
},
success: function (response) {
$("#projectList").setGridParam({ data: response }).trigger("reloadGrid");
},
error: function (error) {
alert(error);
}
});
$("#projectList").jqGrid('filterToolbar', { stringResult: true, searchOnEnter: false, defaultSearch: "cn" });
});