简体   繁体   中英

Search on Ignited Datatables CodeIgniter

It's me again and I need your utmost help :)

I'm working on with my thesis and got a lot work to do and I did searched a lot and yet still I haven't found the right answer to my problem so here I am.

Anyway, i am using Codeigniter and Ignited Datatables to show my records. I have no problem showing the records, but Search and Records Limit are not working. I followed this tutorial: http://www.ahmed-samy.com/php-codeigniter-full-featrued-jquery-datatables-part-1/ It's search is working and we got almost the same code.

Here's mine:

script:

$(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
         });
        },
    } );
});

here's my controller:

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

here's my model:

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();
        }

and my view:

<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>

Thanks much for always helping me. :)

what's the version of DataTables that you are using? If you are using the latest version which is 1.10 then please note that there are lots of changes.

Refer the link Datatables - Upgrade 1.10 . Other than that I won't think there should be any problem.

If you are still facing, then try to use the Developer Tools of Chrome or Firefox and see the Conole tab for the possible errors that could help to dig deeper.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM