最近在做一个项目,时间比较赶,人比较少只能前后端一起撸着袖子上,但前端确实没有深入了解过...只能基于现有的框架,再去套网上的模板,没有深入了解过原理...
现在的问题主要是:后台目前已经传了一个JSONArray到前端,前端已经可以正常接收到后台传来的数据,数据大致如下:
[
{beanTestId: 59, beanTestName: "评测1", id: 244, isTested: 0, itemDescription: ""},
{beanTestId: 59, beanTestName: "评测2", id: 268, isTested: 0, itemDescription: ""}
]
前端的代码如下:
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/static/ui/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/static/ui/themes/icon.css">
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/static/ui/demo.css">
<script type="text/javascript" src="${pageContext.request.contextPath}/static/ui/jquery.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/static/ui/jquery.easyui.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/static/ui/easyloader.js"></script>
</head>
<body>
<div id="dlg" class="easyui-dialog" title="评测" style="width:100%;height:100%;"
data-options="resizable:true,modal:true">
<table id="dg" class="easyui-datagrid" style="width:100%;height:100%;"
data-options="singleSelect:true,collapsible:true">
<thead>
<tr>
<th data-options="field:'beanTestId',width:80">表名 </th>
<th data-options="field:'id',width:80">信息 </th>
<th data-options="field:'isTested',width:100">详细信息</th>
</tr>
</thead>
</table>
</div>
<script type="text/javascript">
var jsonObj = ${testInfos};
var total = jsonObj.length;
console.log(jsonObj);
var datasource = { 'total': total, 'rows':jsonObj};
$("#dg").datagrid('loadData',datasource);
</script>
</body>
在调试控制台处可以看到已经可以接收到后台传来的参数了。但在渲染的时候却报错了:
尝试着断点调试了,发现是下面这里的一个参数没被赋值:
想着继续去找那个参数到底是在哪里被赋值的,但代码实在太多了...加上工期比较赶,实在没办法才来向各位大神提问的。
按网上的例子,js代码似乎只要写成这样就可以了,不知道是不是遗漏了什么,导致框架缺少了一些必要的参数呢?
谢谢各位大神了!