CodeIgniter Forums
jQuery Datatables API with CI4 - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Addins (https://forum.codeigniter.com/forumdisplay.php?fid=34)
+--- Thread: jQuery Datatables API with CI4 (/showthread.php?tid=75467)



jQuery Datatables API with CI4 - monkenWu - 02-08-2020

Hello everyone.

I often use the jQuery DataTables library, so I made this plugin .

Tableslgniter is an plugin base on CodeIgniter4. It will help you use jQuery Datatables in server side mode.

If you need this plugin, you can visit the example and user guide website, or the git page.

example and user guide website
(The complete user guide is currently only have Chinese version. For English,we will add English version to complete user guide soon.But you can use Google Translate to read the user guide first.)

git page


RE: jQuery Datatables API plugin based CI4 - jreklund - 02-08-2020

Hi, just tried the examples on your website. The first one dosen't sort at all. The second are sorting like this:
title1
title10
title11
title2

instead of
title1
title2
...
title10
title11


RE: jQuery Datatables API plugin based CI4 - monkenWu - 02-08-2020

(02-08-2020, 11:31 AM)jreklund Wrote: Hi, just tried the examples on your website. The first one dosen't sort at all. The second are sorting like this:
title1
title10
title11
title2

instead of
title1
title2
...
title10
title11

Hi, maybe my example case is not well designed. Involving the fields of a varchar structure in sorting can cause this problem.
When the sort button is operated, the following query is generated:

SELECT *
FROM `news`
ORDER BY `title` ASC

Actually this query on the database(mysql db) will have the same result.
The sorting of the first example has no effect, because the sorting function is not demonstrated in this example, so the sorting function is not activated.
I will modify the example.


RE: jQuery Datatables API plugin based CI4 - jreklund - 02-09-2020

Hi, yeah MySQL don't like numbers they go for letters only in their natural sorting. Their are ways to allow this type of sorting in MySQL or it can be achieved by sorting in PHP instead. Don't know if this is what you want of your project or not.

DataTables have some plugins you can install to get this type of behavior as well.