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

时间:2015-02-12 10:36:47

标签: datatable

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

<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>

数据表代码如下。

$(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的回应如下。

{"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"}]}

1 个答案:

答案 0 :(得分:1)

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

   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' }
                    ]
                });
            }
        });
    });

您也可以使用success方法在成功方法中控制数据,以确保其正确返回