DataTables warning: table id=dataTable - Requested unknown parameter 'acceptId' for row 0. F...

本文介绍了一种在使用jQuery DataTables插件时遇到的未知参数错误及其解决方案。该错误通常发生在配置文件中指定的参数在数据源中不存在时。文章详细解释了一个具体的例子,并给出了如何修正mRender函数以避免此类问题的方法。
摘要由CSDN通过智能技术生成

重点内容
DataTables warning: table id=dataTable - Requested unknown parameter ‘acceptId’ for row 0. For more information about this error, please see http://datatables.net/tn/4

使用jquery.datatable时发生上面错误,配置例如以下:

table = $("#dataTable").dataTable({
                        "scrollY": "400px", //高度
                        "scrollX": true, //左右滚动栏
                        "ordering":false,//thead上的排序button
                        "bLengthChange": false,//分页条数选择button
                        "bProcessing": true,//显示载入中
                        "bInfo": false,//页脚信息显示
                        "searching":false,//搜索输入框显示
                        "sPaginationType": "full_numbers",//分页显示样式
                        "paging":true,//
                        "sAjaxSource": '<%= basePath %>sellcar/getSellCarOrderList',
                        "bProcessing" : true,
                        "bServerSide" : true,
                        "oLanguage": {  
                                    "sLengthMenu": "每页显示 _MENU_  条",  
                                    "sZeroRecords": "没有找到符合条件的数据",  
                                    "sProcessing": "我也是醉了,正在载入数据...",  
                                    "sInfo": "当前第 _START_ - _END_ 条 共计 _TOTAL_ 条",  
                                    "sInfoEmpty": "没有有记录",  
                                    "sInfoFiltered": "(从 _MAX_ 条记录中过滤)",  
                                    "sSearch": "搜索:",  
                                    "oPaginate": {  
                                        "sFirst": "首页",  
                                        "sPrevious": "前一页",  
                                        "sNext": "后一页",  
                                        "sLast": "尾页"  
                                    }  
                        },
                        "aoColumns": [
                        //{ "sDefaultContent": ' '},
                        { "mData":"brandName",'sClass':'left',
                            "mRender":function(data,type,full) {
                                var cusId = full.customerId;
                                var sellNo = full.sellNo;
                                var content = "<td><input type='checkbox' name='batchAllocated' id='batchAllocated' value='"+cusId+"' sell_no='"+sellNo+"'></td>";
                                return content;
                            }
                        },
                            { "mData":"brandId",
                            "mRender":function(data,type,full){
                                if(full.carBrand!=null){
                                    return full.carBrand.brandName;
                                };
                                return "";
                            }
                        },
                        { "mData":"serieId",
                            "mRender":function(data,type,full){
                                if(full.carSerie!=null){
                                    return full.carSerie.serieName;
                                };
                                return "";
                            }
                        },
                        { "mData":"customeId",
                            "mRender":function(data,type,full){
                                if(full.customer!=null){
                                    return full.customer.userName;
                                };
                                return "";
                            }
                        },
                        { "mData":"phoneNo"},
                        { "mData":"createdFormat"},
                        { "mData":"sellStatus",'sClass':'left',
                            "mRender":function(data,type,full) {
                                var sellStatus = full.sellStatus;
                                var content = "";
                                if(sellStatus==0){
                                    content = "待估车";
                                }else if(sellStatus==10){
                                    content = "估车成功";
                                    if(full.recordStatus == "wlr"){
                                        content = "估车成功,未录入";                               
                                    }else if(full.recordStatus == "ylr"){
                                        content = "已录入";
                                    }
                                    if(full.item !=null){
                                        var item = full.item;
                                        if(item.carStatus == "ysh"){
                                            content = "通过审核";
                                            if(item.carOnSale == 0){
                                                content = "待上架";
                                            }else if(item.carOnSale ==1){
                                                content ="上架";
                                            }else if(item.carOnSale == 2){
                                                content = "下架";
                                            }else if(item.carOnSale == 3){
                                                content = "已售";
                                            }else if(item.carOnSale == 4){
                                                content = "申请下架";
                                            }
                                        }else if(item.carStatus =="dsh"){
                                            content = "待审核";
                                        }else if(item.carStatus == "wsh"){
                                            content = "未通过审核";
                                        }
                                    }
                                }else if(sellStatus==20){
                                    content = "又一次估车";
                                }else if(sellStatus == 30){
                                    content = "估车失败。结束";
                                }else if(sellStatus == 40){
                                    content = "无效信息";
                                }
                                return content;
                            }
                        },
                        { "mData":"acceptId",
                            "mRender":function(data,type,full){
                                if(data !=null){
                                    if(full.acceptUser !=null){
                                        return full.acceptUser.userName;
                                    }
                                }
                            }
                        },
                        { "mData":"carStatus",'sClass':'left',
                            "mRender":function(data,type,full) {
                                var content = "<a href='javascript:void(0);' class='show_info' info_id='"+full.sellNo+"'>查看</a>";
                                return content;
                            }
                        },
                        { "mData":"isAllocated",'sClass':'left',
                        "mRender":function(data,type,full) {
                                var isAllocated = full.isAllocated;
                                var content = "";
                                if(isAllocated==0){
                                    content = "<a href='javascript:void(0);' class='change_info' info_id='"+full.sellNo+"' cus_id='"+full.customerId+"'>分配</a>";
                                }else{
                                    content = "<a href='javascript:void(0);' class='change_info' info_id='"+full.sellNo+"' cus_id='"+full.customerId+"'>又一次分配</a>";
                                }
                                return content;
                            }
                        }],
//                      "bLengthChange": true,// 控制每页显示记录数
                        "iDisplayLength": 10, // 每页显示数量
                        "fnServerData" : function(sSource, aoData, fnCallback) {
                            $.ajax({
                                "type" : 'post',
                                "url" : sSource,
                                "dataType" : "json",
                                "data" : {
                                    aoData : JSON.stringify(aoData),
                                    searchData: JSON.stringify(searchData)
                                },
                                "success" : function(resp) {
                                    fnCallback(resp);
                                    var datas=resp.aaData;                              
                                },
                                error: function(resp){
                                }
                            });
                        }/* ,
                        "fnRowCallback": function(nRow, aData, iDisplayIndex) {
//                          当创建了行。但还未绘制到屏幕上的时候调用,通经常使用于改变行的class风格,此处用于显示‘表格序号’ 
                            $('td:eq(0)', nRow).html(iDisplayIndex+1);
                            return nRow;
                        } */
                    });

提示acceptId找不到,解决方式:

{ "mData":"acceptId",
                            "mRender":function(data,type,full){
                                if(data !=null){
                                    if(full.acceptUser !=null){
                                        return full.acceptUser.userName;
                                    }
                                }else{
                                    return "";
                                }
                            }
                        }

在写mRender时,必须全部路径都要有返回值。做了空值推断,可是没有给返回值所以出现了上述错误。做个记录。以备兴许使用。

转载于:https://www.cnblogs.com/cxchanpin/p/7064771.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值