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
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题