duanpu1111 2014-08-10 13:54
浏览 38
已采纳

将DataTable与Codeigniter一起使用时,它显示的是处理而不是显示数据

I'm trying to use DataTables with CodeIgniter.

Here is what I have done so Far.

1) Added the IgnitedDatatables Library to my library and called it to my datatables controller,

$this->load->library('Datatables.php');

2) View

<table id="ManageForms" class="table table-bordered table-condensed table-hover table-striped">
    <thead>
        <tr>
            <th>Form Name</th>
            <th>Browser</th>
            <th>Platform(s)</th>
            <th>Engine version</th>
            <th>CSS grade</th>
        </tr>
    </thead>
</table>

<script>
    $(document).ready(function() {
        $('#ManageForms').dataTable({
            "processing":true,
            "serverSide":true,
            "bProcessing":true,
            "sServerMethod": "POST",
            "sAjaxSource": "{{base_url()}}admin/configurations/listForms_DT/",
            "iDisplayLength": 10,
            "aLengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]],
            "aaSorting": [[0, 'asc']],
            "aoColumns": [
                { "bVisible": true, "bSearchable": true, "bSortable": true },
                { "bVisible": true, "bSearchable": true, "bSortable": true },
                { "bVisible": true, "bSearchable": true, "bSortable": true }
            ],
            "columns": [
                { "data": "FormName" }
            ],
            'fnServerData'   : function(sSource, aoData, fnCallback){
                $.ajax ({
                    'dataType': 'json',
                    'type'    : 'POST',
                    'url'     : sSource,
                    'data'    : aoData,
                    'success' : fnCallback
                }); //end of ajax
            }

        });
    });
</script>

3) Data in Json Return in this Form from the Path:

 {"data_DT":[{"FormID":"1","FormName":"Dashboard","FormPath":"#","FormCIPath":"admin\/dashboard\/System","IsMenuLink":"1","MenuID":"1","FormRoleID":"1","RoleID":"1","IsDeleteable":"1","IsEditable":"1","IsCreatable":"1"},{"FormID":"2","FormName":"Dashboard","FormPath":"#","FormCIPath":"admin\/dashboard\/Users","IsMenuLink":"1","MenuID":"2","FormRoleID":"2","RoleID":"1","IsDeleteable":"1","IsEditable":"1","IsCreatable":"1"},{"FormID":"3","FormName":"Residensials","FormPath":"#","FormCIPath":"#","IsMenuLink":"1","MenuID":"3","FormRoleID":"3","RoleID":"1","IsDeleteable":"1","IsEditable":"1","IsCreatable":"1"},{"FormID":"6","FormName":"Configuration","FormPath":"#","FormCIPath":"#","IsMenuLink":"1","MenuID":"6","FormRoleID":"4","RoleID":"1","IsDeleteable":"1","IsEditable":"1","IsCreatable":"1"},{"FormID":"7","FormName":"ManageForms","FormPath":"#","FormCIPath":"admin\/configurations\/ManageForms","IsMenuLink":"1","MenuID":"7","FormRoleID":"5","RoleID":"1","IsDeleteable":"1","IsEditable":"1","IsCreatable":"1"}]}

Now the Problem is that my DataTables instead of showing days, shows Processing??

I am not sure where did i go wrong, please if anyone can fix the issue or redirect me what did i do wrong?

  • 写回答

1条回答 默认 最新

  • dpbz14739 2014-08-11 20:04
    关注

    This message means, DataTable is unable to read properly your data.

    Using default settings, your ajax request must return data into aaData object.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 驱动学习 环境部署中的问题
  • ¥15 【急】在线问答CNC雕刻机的电子电路与编程
  • ¥60 在mc68335芯片上移植ucos ii 的成功工程文件
  • ¥15 笔记本外接显示器正常,但是笔记本屏幕黑屏
  • ¥15 Python pandas
  • ¥15 蓝牙硬件,可以用哪几种方法控制手机点击和滑动
  • ¥15 生物医学数据分析。基础课程就v经常唱课程舅成牛逼
  • ¥15 云环境云开发云函数对接微信商户中的分账功能
  • ¥15 空间转录组CRAD遇到问题
  • ¥20 materialstudio计算氢键脚本问题