====================================================================
<script>
$(document).ready(function () {
$('#historyToolList').datagrid({
url: '/tool/DateListToolUpdateHistory',
method: 'get',
width: '100%',
height: '160',
rownumbers: true,
singleSelect: true,
queryParams: { toolId: '1' }
});
});
</script>
<table id="historyToolList" class="easyui-datagrid"
>
<thead>
<tr>
<th data-options="field:'updateDate',width:80">修改日期</th>
<th data-options="field:'updateUserId',width:80">修改人</th>
<th data-options="field:'T_id',width:60">模具ID</th>
<th data-options="field:'supplier_C',width:80">供应商</th>
<th data-options="field:'owner_C',width:80">所属运营</th>
<th data-options="field:'fixedAssetNo_C',width:80">固定资产号</th>
<th data-options="field:'useStatus_C',width:80">使用状态</th>
<th data-options="field:'toolingStatus_C',width:80">模具状态</th>
<th data-options="field:'usableCavity_N',width:80">现在的模具腔数</th>
<th data-options="field:'cycleTime_N',width:80">每模时间</th>
<th data-options="field:'efficiency_D',width:80">效率</th>
<th data-options="field:'usedToolingLife_N',width:80">已经使用的模具寿命</th>
<th data-options="field:'byPart_D',width:80">零件预测量</th>
<th data-options="field:'machineSpeedSpm_N',width:80">冲压速率</th>
</tr>
</thead>
</table>
后台处理
public ActionResult DateListToolUpdateHistory(string toolId)
{
if (String.IsNullOrEmpty(toolId) || toolId.Equals("0"))
{
return Json(" ", JsonRequestBehavior.AllowGet);
}
else
{
int toolId_I = Convert.ToInt32(toolId);
var urList = from t in db.ToolUpdateHistories
where t.T_id == toolId_I
select t;
return Json(urList.ToList(), JsonRequestBehavior.AllowGet);
}
}
====================================================================
以上报错浏览器报错:Uncaught TypeError: Cannot read property 'length' of undefined
如果不传参数则报错
Failed to load resource: the server responded with a status of 500 (Internal Server Error)
这个俩个错误在MVC4 框架结合easyui datagrid 出问题的,经过反复测试 修改排除法查找.
得出的结论 应该是关于浏览器 加载页面时 应该先加载了JS 从而 执行了 DateListToolUpdateHistory 但是传过来却是Null
虽然后台对 null 做了处理,返回 空字符的 JSON ,但是加载完JS后,页面的参数已经有了 第二次执行DateListToolUpdateHistory 这时候,easyui 就报错了,俩次重复的绑定