![]() |
Datatables for Codeigniter 3 - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Datatables for Codeigniter 3 (/showthread.php?tid=84989) |
Datatables for Codeigniter 3 - brianjamestorr - 11-30-2022 Hi Does anyone have datatables library or anything to use with CI3, and to support joins because of search in database table. Main problem with this i have is that i need to make model for each database table and new controller. For example i have Vehicles controller and model, and under vehicles model i want to have vehicles insurance, vehicles services tables but i don't want to copy/paste same code for datatables in same file. Currently i am using it like this Model: PHP Code: var $table = 'vehicle'; Controller: PHP Code: $data = array(); RE: Datatables for Codeigniter 3 - superior - 11-30-2022 There is a library available maybe this makes it easier for you? https://github.com/cahyadsn/ci-datatables RE: Datatables for Codeigniter 3 - InsiteFX - 12-01-2022 This may also help you out. DataTables AJAX Pagination with Search and Sort in CodeIgniter 3 RE: Datatables for Codeigniter 3 - brianjamestorr - 12-01-2022 (11-30-2022, 12:30 PM)superior Wrote: There is a library available maybe this makes it easier for you? Thanks man this solution is perfect and really easy to use ![]() I use it this way in model/controller because of logic that i don't want to do in model. I hope this will help someone. My model: PHP Code: $this->datatables->select('Id, Title, Plate'); My controller: PHP Code: $data = []; My view, ajax: Code: var table = $('#data-table').DataTable({ (12-01-2022, 12:19 AM)InsiteFX Wrote: This may also help you out. I tried this code and this one is too much to write or to place in function for reuse, also those 3 lines throwing error because default when you load table you doesn't have indexes set of PHP Code: $postData['order'] If someone wants to use this you need to check for PHP Code: isset($_POST['order']) PHP Code: $rowperpage = $postData['length']; // Rows display per page |