![]() |
jQuery Datatables Integration - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22) +--- Thread: jQuery Datatables Integration (/showthread.php?tid=41776) |
jQuery Datatables Integration - El Forum - 05-16-2011 [eluser]Destreyf[/eluser] Hello, i have a piece of code to present today that allows easier interaction with jQuery DataTables by Allan Jardine. I was recently faced with a scenario where i needed to be able to easily return a data structure and print it out, (JSON loading) the given code seemed too heavy, so i have here today a small Library, that does just that, in a simple move. This is a Active Record driven library, it balances on that, allowing you to use alias's in your columns, and tables, its just as simple as issuing a regular Active Record Query. A couple downsides to the code is it requires PHP5+, however, i don't see much downside in that, it also is written for Codeigniter 1.7.X i haven't moved to 2.0 quite yet on this project that I'm busy with. Code: <?php Continued Next Post! jQuery Datatables Integration - El Forum - 05-16-2011 [eluser]Destreyf[/eluser] Continued! The usage for this code is very simple. Code: <?php A basic explanation would that you build you query, outside of the datatables library (using models, ect) and once you get it to the point where you're ready, assign it to a variable and pass it in as an argument, along with the table name, it will automatically build all of the order by columns, and the searches. Some alternative syntax is as follows: Code: class Example extends Controller { I believe this to be a simple alternative, my setting for jQuery DataTables by Allan Jardine are as follows: Code: $(document).ready(function() { The code provided here is provided as is, with no warranty - Use at your own risk or advantage, a few notes to be heard. This does not Currently support the "Non Searchable" and "Non Sortable" options housed by the jQuery DataTables plug-in, but i plan on adding those soon, as well as filling in some additional functionality, however, my free time is sparse, and i figured I'd contribute back to a fantastic community with what little i can. jQuery Datatables Integration - El Forum - 05-16-2011 [eluser]cryogenix[/eluser] erm have you seen our implementation of this already? http://ellislab.com/forums/viewthread/160896/ if you don't mind forking from there, your active record version can refactor our library. =) jQuery Datatables Integration - El Forum - 05-16-2011 [eluser]Destreyf[/eluser] Hello cryogenix, i have seen your code, and i have used it, however, i felt it was too enforced on how to access it, the active record implementation is simple, as you can see, and if you'd like to integrate the functionality, please do, i would love for my code to be used in a manor that helps everyone. However, for my needs, what i have is sufficient, i will be posting a few more updates to my code in order to add a couple bits of functionality, but for the most part, its ready to go out of the box. jQuery Datatables Integration - El Forum - 05-17-2011 [eluser]4ever[/eluser] Could you bh and explain me simply what this code serves for? I was on the link datatables just don't know what does it serve for. jQuery Datatables Integration - El Forum - 05-17-2011 [eluser]Destreyf[/eluser] DataTables is a jQuery library, designed to make Pagination, Searching, Limiting, and Sorting SUPER easy, and while it does, i deal with some 1+million records at some times that have to be sorted out, so using its native javascript HTML Table functionality does not work with my needs, so i used its integrated AJAX loading functionality, to retrieve a backend result generated JSON object, all this Library does, it makes formatting the data, and getting a response easier with as little code as possible. |