Paginator |
[eluser]JonoB[/eluser]
The core pagination class is super easy to use, but didnt provide the flexibility and features that I was looking for. I wanted to be able to sort column headings, choose the page size, and more. This class is based heavily on the CI 2.0 core Pagination Class. However, if you pass in the right parameters, it will hopefully work some magic for you and create a table with sortable headers, as well as selectable page sizes Although the core Pagination class works off the offset param, this class uses the the page number and page size, as well as the sort order and sort direction. For this to happen, the uri has to be constructed in a very specific order of: /page_no/page_size/sort_by/sort_order. So, for example, products/index/2/25/code/desc means that I want to show the 2nd page, 25 records, sorted by code, sorted in descending order Note that this class does not yet work with query strings Please excuse me if this doesnt meet all the CI coding requirements. I'm still getting used to the framework and MVC in general. Any comments, suggestions, bug fixes are welcome. Grab the latest version from https://github.com/JonoB/CI-Paginator
[eluser]Carlton[/eluser]
Just wanted to say thanks for such a great library, works perfectly. I was trying to return "->result_array()" from my model but it turns out this had to be "->result()" Suprised there aren't more replies to this thread, maybe because the library works so well ;-)
[eluser]JonoB[/eluser]
[quote author="Carlton" date="1313424209"]Just wanted to say thanks for such a great library, works perfectly. I was trying to return "->result_array()" from my model but it turns out this had to be "->result()" Suprised there aren't more replies to this thread, maybe because the library works so well ;-)[/quote] You are welcome. I've actually made a lot of enhancements since then...will upload to BitBucket asap.
[eluser]JonoB[/eluser]
I've put the repo on github now: https://github.com/JonoB/CI-Paginator Apologies that some of the tab spacing is a bit out of whack...bitbucket seems to screw up the formatting for some reason.
[eluser]Carlton[/eluser]
I noticed that you can do something like this to make a link to a particular link followed by an ID (from the DB) Code: $columns = array( Is there functionality for something similar with a checkbox so I can end up with something like the following where my value "football" is coming from a database field? Code: <input type="checkbox" name="sports" value="football" /> I'm thinking I will have to add some code to "create_table" function and check for some new parameters to be supplied in the column config array
[eluser]JonoB[/eluser]
I've come up against a very similar issue as well. The way that I handled it was as follows: 1. Define your table headings as usual, with the checkbox heading something like this: Code: $columns = array( 2. As normal, set up your paginator config vars, and then initialise Code: $this->paginator->initialize($config); 3. Pass the following vars to your view: Code: $data['pagination'] = $this->paginator->create_links(); 4. Don't generate the table using the lib. Rather, generate your table manually, and pass the table records to the view: Code: $data['table_records'] = $this->Some_model->get_something( 5. View Code: <table>
[eluser]Carlton[/eluser]
Thanks for the quick reply, I'll definitely be giving this a try
[eluser]nl_vinyl[/eluser]
Does anybody have a simple example of how to implement this? The Pagination setup I have now uses a model with two functions. One for counting the total amount of records and one for actually fetching the records with the limit and start that is being passed. |
Welcome Guest, Not a member yet? Register Sign In |