I have modified CI Pagination library into an ajax based pagination. Check here
This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.
The active forums are here.
March 19, 2008 5:26pm
Subscribe [11]#1 / Mar 19, 2008 5:26pm
I have modified CI Pagination library into an ajax based pagination. Check here
#2 / Mar 19, 2008 7:21pm
Check the update. Open Wiki, find ‘AJAX Pagination’
#3 / Mar 19, 2008 7:27pm
You might want to throw some [ code ] tags into your submission Gin2, its quite difficult to read without them.
#4 / Mar 19, 2008 8:26pm
Oooppsss sorryyyy!! It’a done ( with
!!! Thanks wireddesignz!
#5 / Mar 19, 2008 9:08pm
It’s look like it’s missing the informations about witch JS library should be used with your script or I misunderstood something ? Maybe a full real world using DB example should be nice too ?
#6 / Mar 19, 2008 10:10pm
Can this sample help you?
CONTROLLER: my_data_page.php
<? class My_data_page extends Controller{
function My_data_page(){
parent::Controller();
$this->load->library('table');
$this->load->library('Ajax_pagination');
}
function index(){
$data['makeColumns'] = $this->makeColumns();
$data['getTotalData'] = $this->getTotalData();
$data['perPage'] = $this->perPage();
$this->load->view('my_data_page', $data);
}
//Pull 'name' field records from table 'contact'
function getData(){
$page = $this->input->post('page'); //Look at $config['postVar']
if(!$page):
$offset = 0;
else:
$offset = $page;
endif;
$sql = "SELECT name FROM contact LIMIT ".$offset.", ".$this->perPage();
$q = $this->db->query($sql);
return $q->result();
}
function getTotalData(){
$sql = "SELECT * FROM people";
$q = $this->db->query($sql);
return $q->num_rows();
}
function perPage(){
return 10; //define total records per page
}
//Generate table from array
function makeColumns(){
$contact = $this->getData();
foreach($contact as $cont):
$data[] = $cont->name;
endforeach;
return $this->table->make_columns($data, 6); //6 colums maximum
}
}
?>
VIEW: my_data_page.php
<s\cript type="text/javascript" src="path-to-prototype.js"></s\cript>
<div id="content">
<?
$config['first_link'] = 'First';
$config['div'] = 'content'; //Div tag id
$config['base_url'] = 'index.php/my_data_page';
$config['total_rows'] = $getTotalData;
$config['per_page'] = $perPage;
$config['postVar'] = 'page';
$this->ajax_pagination->initialize($config);
print $this->ajax_pagination->create_links();
//PRINT TABLE
print $this->table->generate($makeColumns);
?>
</div>
#7 / Mar 19, 2008 10:15pm
Yeah that’s cool. But for the JS side, what I must do exactly ?
Do you have a sample snippet of code using Jquery or Scriptaculous ? (or any other web 2.0 JS lib)
#8 / Mar 19, 2008 10:22pm
Addition: Initialize my_data_page in your page loader (i.e: my_page_data_loader.php)
————————————————————
CONTROLLER: my_data_page_loader.php
<? class My_data_page_loader extends Controller{
My_data_page_loader(){
parent::Controller;
}
function index(){
$this->load->view('my_data_page_loader');
}
}
VIEW: my_data_page_loader.php
#9 / Mar 19, 2008 10:25pm
before and after ‘new Ajax.Updater ....’ please insert javas\cript opening and closing tag;
#10 / Mar 19, 2008 10:57pm
bye for now, it’s morning in Indonesia. And, i have to sleep.. 😛
#11 / Mar 31, 2008 5:53pm
Can you please post your JS for us?
#12 / Mar 31, 2008 6:13pm
#13 / Mar 31, 2008 6:24pm
I know what he’s using, I want to see his actually JS to see what he’s sending and what he’s getting back, as I’m using jQuery.
How is he updating his table via AJAX, etc.
#14 / Jun 17, 2008 5:13am
Great job Ajax Pagination.
<opinion>
If you post a modification people wants complete examples. You missed the client side JS with parameters dealing. I can imagine this, but its better you post your own complete and working examples, isn’t it?
If a can help with a class modification , i’ll put all the examples.
</opinion>
#15 / Jul 08, 2008 8:54am
Hi Gin2
What you have done is just what I need for my project thanks, so I’ve implemented your code - w/o the later modification and get this output:
<div id="content">
<table border="0" cellpadding="4" cellspacing="0">
... ... ...
</table>
<b>1</b>
<a href="#">2</a>
<a href="#">></a>
</div>
[onclick replaced by click for this post]
Which all seems to look OK, no errors in Firebug. But the onClick event never seems to fire. Now I’m not in any way a JS programmer so any clues on a way forward would be appreciated.