easyui 俩个错误 解决方案

====================================================================

<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 就报错了,俩次重复的绑定

  • 4
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值