首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >DataTables警告:表id=example -请求的行0的未知参数'census_health.memberid‘

DataTables警告:表id=example -请求的行0的未知参数'census_health.memberid‘
EN

Stack Overflow用户
提问于 2015-02-12 18:36:47
回答 1查看 952关注 0票数 1

当前在使用Datable时遇到错误。下面是我在视图文件中的代码。错误/警告: DataTables警告:表id=example -请求的行0的未知参数'census_health.memberid‘

代码语言:javascript
复制
<table id="example" class="display" width="100%" cellspacing="0">
                            <thead>
                                <tr>
                                    <th>Member Id</th>
                                    <th>Name</th>
                                    <th>Jss Card No</th>
                                    <th>Bank Account No</th>
                                    <th>Mamta Yojana Benefit</th>
                                    <th>Home Visit</th>
                                    <th>TT1</th>
                                    <th>TT2</th>
                                    <th>TT Status</th>
                                </tr>
                            </thead>

                            <tfoot>
                                <tr>
                                    <th>Member Id</th>
                                    <th>Name</th>
                                    <th>Jss Card No</th>
                                    <th>Bank Account No</th>
                                    <th>Mamta Yojana Benefit</th>
                                    <th>Home Visit</th>
                                    <th>TT1</th>
                                    <th>TT2</th>
                                    <th>TT Status</th>
                               </tr>
                            </tfoot>
                        </table>

Datatable代码如下所示。

代码语言:javascript
复制
$(document).ready(function() {

    var oTable = $('#example').dataTable({
        "bProcessing": true,
        "bServerSide": true,
        "bRetrieve": true,
        "bDestroy": true,
        "sAjaxSource": "../../loadReportDataAjax/",
        "aoColumns": [
                      { mData: 'census_health.memberid' },
                      { mData: 'hh_member.name' },
                      { mData: 'census_health.jss_card_no' },
                      { mData: 'census_health.bank_account_no' },
                      { mData: 'census_health.mamta_yojana_benefit' },
                      { mData: 'census_health.home_visit' },
                      { mData: 'census_pregnant_anc_checkup.TT1' },
                      { mData: 'census_pregnant_anc_checkup.TT2' },
                      { mData: 'census_pregnant_anc_checkup.tt_status' }
                ],
        "bJQueryUI": true,
        "sPaginationType": "full_numbers",
        "iDisplayStart ":10,

        'fnServerData': function (sSource, aoData, fnCallback) {
            $.ajax
            ({
                'dataType': 'json',
                'type': 'POST',
                'url': sSource,
                'data': aoData,
                'success': fnCallback
            });
        }
    });
});

Json响应如下。

代码语言:javascript
复制
{"sEcho":1,"iTotalRecords":"4","iTotalDisplayRecords":"4","aaData":[{"census_health.memberid":"26-391-1-20-104-59502-2","hh_member.name":"LATIKA NAIK","census_health.jss_card_no":"1111111111","census_health.bank_account_no":"2147483647","census_health.mamta_yojana_benefit":"Yes","census_health.home_visit":"EMPTY","census_pregnant_anc_checkup.TT1":"17-07-2013","census_pregnant_anc_checkup.TT2":"18-09-2013","census_pregnant_anc_checkup.tt_status":"Pending"},{"census_health.memberid":"26-391-1-20-104-59502-2","hh_member.name":"LATIKA NAIK","census_health.jss_card_no":"33333","census_health.bank_account_no":"363636","census_health.mamta_yojana_benefit":"Yes","census_health.home_visit":"ANM","census_pregnant_anc_checkup.TT1":"17-07-2013","census_pregnant_anc_checkup.TT2":"18-09-2013","census_pregnant_anc_checkup.tt_status":"Pending"},{"census_health.memberid":"26-391-1-20-104-59502-2","hh_member.name":"LATIKA NAIK","census_health.jss_card_no":"1111111111","census_health.bank_account_no":"2147483647","census_health.mamta_yojana_benefit":"Yes","census_health.home_visit":"EMPTY","census_pregnant_anc_checkup.TT1":"17-07-2013","census_pregnant_anc_checkup.TT2":"18-09-2013","census_pregnant_anc_checkup.tt_status":"Pending"},{"census_health.memberid":"26-391-1-20-104-59502-2","hh_member.name":"LATIKA NAIK","census_health.jss_card_no":"333331111","census_health.bank_account_no":"2147483647","census_health.mamta_yojana_benefit":"No","census_health.home_visit":"Anganwadi","census_pregnant_anc_checkup.TT1":"17-07-2013","census_pregnant_anc_checkup.TT2":"18-09-2013","census_pregnant_anc_checkup.tt_status":"Pending"}]}
EN

回答 1

Stack Overflow用户

发布于 2015-02-12 19:02:59

重构你的javascript并把你的表声明放在一个ajax调用中。

代码语言:javascript
复制
   var oTable = null;
    $(document).ready(function() {
        $.ajax({
            url: "../../loadReportDataAjax/",
            data: JSON.stringify({ rvm: data }),
            contentType: 'application/json',
            dataType: 'json',
            type: 'POST',
            success: function(data) {

                oTable = $('#doctor_details_requests_tests_id').dataTable({
                    "data": data['aaData'],
                    "order": [[0, "desc"]],
                    "aoColumns": [
                        { mData: 'census_health.memberid' },
                        { mData: 'hh_member.name' },
                        { mData: 'census_health.jss_card_no' },
                        { mData: 'census_health.bank_account_no' },
                        { mData: 'census_health.mamta_yojana_benefit' },
                        { mData: 'census_health.home_visit' },
                        { mData: 'census_pregnant_anc_checkup.TT1' },
                        { mData: 'census_pregnant_anc_checkup.TT2' },
                        { mData: 'census_pregnant_anc_checkup.tt_status' }
                    ]
                });
            }
        });
    });

您还可以在console.log方法中成功您的数据,以确保其正确返回

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28475239

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档