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 python点云生成mesh精度不够怎么办
  • ¥15 QT C++ 鼠标键盘通信
  • ¥15 改进Yolov8时添加的注意力模块在task.py里检测不到
  • ¥50 高维数据处理方法求指导
  • ¥100 数字取证课程 关于FAT文件系统的操作
  • ¥15 如何使用js实现打印时每页设置统一的标题
  • ¥15 安装TIA PortalV15.1报错
  • ¥15 能把水桶搬到饮水机的机械设计
  • ¥15 Android Studio中如何把H5逻辑放在Assets 文件夹中以实现将h5代码打包为apk
  • ¥15 使用小程序wx.createWebAudioContext()开发节拍器