【问题标题】:Search on Ignited Datatables CodeIgniter搜索点燃的数据表 CodeIgniter
【发布时间】:2015-03-23 15:51:18
【问题描述】:

又是我,我需要你的最大帮助:)

我正在写我的论文,还有很多工作要做,我确实搜索了很多,但我仍然没有找到我的问题的正确答案,所以我在这里。

无论如何,我正在使用 Codeigniter 和 Ignited Datatables 来显示我的记录。我显示记录没有问题,但搜索和记录限制不起作用。我遵循了本教程:http://www.ahmed-samy.com/php-codeigniter-full-featrued-jquery-datatables-part-1/ 它的搜索工作正常,我们得到了几乎相同的代码。

这是我的:

脚本:

$(document).ready(function(){
    var oTable = $('#clientDT').dataTable( {
        "bProcessing": true,
        "bServerSide": true,
        "sAjaxSource": 'http://localhost:81/ORPS/client/viewClientsJSON',
        "bJQueryUI": true,
        "sPaginationType": "full_numbers",
        "iDisplayStart ": 10,
        "oLanguage": {
            "sProcessing": "<img src='http://localhost:81/ORPS/images/loading-icons/loading3.gif'>"
        },
        "fnInitComplete": function() {
                //oTable.fnAdjustColumnSizing();
         },
        'fnServerData': function(sSource, aoData, fnCallback)
        {
         $.ajax
         ({
            'dataType': 'json',
            'type'    : 'POST',
            'url'     : sSource,
            'data'    : aoData,
            'success' : fnCallback
         });
        },
    } );
});

这是我的控制器:

function viewClientsJSON(){
            $clientList = $this->clientmodel->clientDT();
            return $clientList;
        }

这是我的模型:

function clientDT(){
            $this->datatables->select('PersonId, LastName, FirstName, MiddleName')
            ->where('PersonTypeId', '1')
            ->where('IsActive', '1')
            ->add_column('Action', get_buttons('client/viewClient/$1', 'client/editClient/$1', '$1'), 'PersonId')
            ->from('person');

            echo $this->datatables->generate();
        }

我的看法:

<div class="table-responsive addMarginTop">
<table id="clientDT" class="table table-condensed table-striped table-hover">
    <thead>
        <tr>
            <th>ID</th>
            <th>Last Name</th>
            <th>First Name</th>
            <th>Middle Name</th>
            <th></th>
        </tr>
    </thead>
    <tbody>
    </tbody>
</table>

非常感谢你一直帮助我。 :)

【问题讨论】:

  • 搜索时浏览器控制台中是否有任何错误或响应消息?还要检查您是否使用了点燃数据表所需的正确版本的数据表和 jquery js 文件。

标签: php jquery codeigniter jquery-datatables


【解决方案1】:

您使用的 DataTables 版本是什么?如果您使用的是 1.10 的最新版本,请注意其中有很多更改。

参考链接Datatables - Upgrade 1.10。除此之外,我认为应该没有任何问题。

如果您仍然遇到问题,请尝试使用 Chrome 或 Firefox 的 开发者工具,并查看 Conole 标签以了解可能有助于深入挖掘的错误。

【讨论】:

    猜你喜欢
    • 2018-07-22
    • 1970-01-01
    • 1970-01-01
    • 2014-10-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-29
    • 1970-01-01
    相关资源
    最近更新 更多