Part of the EllisLab Network
   
1 of 2
1
AJAX Pagination with CI Pagination Library
Posted: 19 March 2008 04:26 PM   [ Ignore ]  
Summer Student
Avatar
Total Posts:  8
Joined  03-19-2008

I have modified CI Pagination library into an ajax based pagination. Check here

Profile
 
 
Posted: 19 March 2008 06:21 PM   [ Ignore ]   [ # 1 ]  
Summer Student
Avatar
Total Posts:  8
Joined  03-19-2008

Check the update. Open Wiki, find ‘AJAX Pagination’

Profile
 
 
Posted: 19 March 2008 06:27 PM   [ Ignore ]   [ # 2 ]  
Sr. Research Associate
Avatar
RankRankRankRankRank
Total Posts:  3198
Joined  06-10-2007

You might want to throw some [ code ] tags into your submission Gin2, its quite difficult to read without them.

 Signature 

URI Language Identifier | Modular Extensions - HMVC | View Object | Widget plugin | Access Control library

Profile
 
 
Posted: 19 March 2008 07:26 PM   [ Ignore ]   [ # 3 ]  
Summer Student
Avatar
Total Posts:  8
Joined  03-19-2008

Oooppsss sorryyyy!! It’a done ( with !!! Thanks wireddesignz!

Profile
 
 
Posted: 19 March 2008 08:08 PM   [ Ignore ]   [ # 4 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  801
Joined  04-20-2006

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 ?

 Signature 

Un blog seo white-hat expliquant quelques techniques intéressantes sur le seo black hat

Ionize CMS - Webdesigner CMS based on CodeIgniter
www.ionizecms.com

My website: Webagency Too Pixel

Profile
 
 
Posted: 19 March 2008 09:10 PM   [ Ignore ]   [ # 5 ]  
Summer Student
Avatar
Total Posts:  8
Joined  03-19-2008

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($data6); //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
Profile
 
 
Posted: 19 March 2008 09:15 PM   [ Ignore ]   [ # 6 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  801
Joined  04-20-2006

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)

 Signature 

Un blog seo white-hat expliquant quelques techniques intéressantes sur le seo black hat

Ionize CMS - Webdesigner CMS based on CodeIgniter
www.ionizecms.com

My website: Webagency Too Pixel

Profile
 
 
Posted: 19 March 2008 09:22 PM   [ Ignore ]   [ # 7 ]  
Summer Student
Avatar
Total Posts:  8
Joined  03-19-2008

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

<s\cript type="text/javascript" src="path/to/prototype.js"></s\cript>

<
div id="content">your my_data_page will be displayed here</div>

<
div id="response" style="display:none">ajax response</div>

<
sc\ript type="text/javascrpt>">new Ajax.Updater('content','index.php/my_data_page',{onLoading:function(request){Element.show('response')}onComplete:function(request){Element.hide('response')}method'post'parameters:{nothing:'todo'}evalScripts:true});</sc\ript 
Profile
 
 
Posted: 19 March 2008 09:25 PM   [ Ignore ]   [ # 8 ]  
Summer Student
Avatar
Total Posts:  8
Joined  03-19-2008

before and after ‘new Ajax.Updater ....’ please insert javas\cript opening and closing tag;

Profile
 
 
Posted: 19 March 2008 09:57 PM   [ Ignore ]   [ # 9 ]  
Summer Student
Avatar
Total Posts:  8
Joined  03-19-2008

bye for now, it’s morning in Indonesia. And, i have to sleep..  tongue laugh

Profile
 
 
Posted: 31 March 2008 04:53 PM   [ Ignore ]   [ # 10 ]  
Grad Student
Rank
Total Posts:  33
Joined  12-12-2007

Can you please post your JS for us?

Profile
 
 
   
1 of 2
1