douyuefei3546 2014-08-21 15:34
浏览 48
已采纳

如果未定义列,则数据表会给出错误

I'm following this guide: http://www.ahmed-samy.com/php-codeigniter-full-featrued-jquery-datatables-part-1/

Their script is:

<script type="text/javascript">
    $(document).ready(function () {
        var oTable = $('#big_table').dataTable({
            "bProcessing": true,
            "bServerSide": true,
            "sAjaxSource": '<?php echo base_url(); ?>index.php/subscriber/datatable',
            "bJQueryUI": true,
            "sPaginationType": "full_numbers",
            "iDisplayStart ": 20,
            "oLanguage": {
                "sProcessing": "<img src='<?php echo base_url(); ?>assets/images/ajax-loader_dark.gif'>"
            },
            "fnInitComplete": function () {
                //oTable.fnAdjustColumnSizing();
            },
            'fnServerData': function (sSource, aoData, fnCallback) {
                $.ajax
                ({
                    'dataType': 'json',
                    'type': 'POST',
                    'url': sSource,
                    'data': aoData,
                    'success': fnCallback
                });
            }
        });
    });
</script>

Here is my script:

    <script>
        $(document).ready(function() {
            var oTable = $('#ManageForms').dataTable({

                "bServerSide":true,
                "bProcessing":true,
                "bJQueryUI": true,
                "sPaginationType": "full_numbers",
                //"bFilter":true,
                "sServerMethod": "POST",
                "sAjaxSource": "{{base_url()}}admin/configurations/listForms_DT/",
                "iDisplayLength": 2,
               // "aLengthMenu": [[2, 25, 50, -1], [2, 25, 50, "All"]],
//                "sEcho": 1,
/*                "columns":[
                    {data:"FormName"},
                    {data:"FormPath"},
                    {data:"FormCIPath"},
                    { "data": null,
                        "defaultContent": "<button>Edit</button>",
                        "targets": -1
                    }
                ],*/
                'fnServerData'   : function(sSource, aoData, fnCallback){
                    $.ajax ({
                        'dataType': 'json',
                        'type'    : 'POST',
                        'url'     : sSource,
                        'data'    : aoData,
                        'success' : fnCallback
                    }); //end of ajax
                }

            });
        } );
    </script>

In tutorial they are not using columns and there table is working fine even with the search, but if I don't use columns which I have commented out, i get this error:

DataTables warning: table id=ManageForms - Requested unknown parameter '0' for row 0. For more information about this error, please see http://datatables.net/tn/4

If I do use the columns, datatables work fine but my search doesn't work. Why is it important for me to use columns but in tutorial they have not?

  • 写回答

1条回答 默认 最新

  • douzhi7070 2014-08-21 16:00
    关注

    Where are you generating the table?

    $this->table->generate();
    

    Also, to search (filter), you need to append:

    fnSetFilteringDelay(700); //delay amount
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 求三轴之间相互配合画圆以及直线的算法
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 自己瞎改改,结果现在又运行不了了
  • ¥15 链式存储应该如何解决
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站