Part of the EllisLab Network
   
1 of 2
1
AJAX Pagination with CI Pagination Library
Posted: 19 March 2008 03: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

 Signature 

Devil with Mac
Gin2[Kronika]

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

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

 Signature 

Devil with Mac
Gin2[Kronika]

Profile
 
 
Posted: 19 March 2008 05:27 PM   [ Ignore ]   [ # 2 ]  
Sr. Research Associate
RankRankRankRankRank
Total Posts:  2634
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 - PHP5 | Modular Separation - PHP5 | Widget plugin | Access Control library

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

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

 Signature 

Devil with Mac
Gin2[Kronika]

Profile
 
 
Posted: 19 March 2008 07:08 PM   [ Ignore ]   [ # 4 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  833
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 

All CodeIgniter resources into one place?
http://www.codeigniterdirectory.com

Buildon.net - The PHP Frameworks Showcase - Add your links!
http://www.buildon.net

My website: Création de sites Genève, Too Pixel

Profile
 
 
Posted: 19 March 2008 08: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($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>
 Signature 

Devil with Mac
Gin2[Kronika]

Profile
 
 
Posted: 19 March 2008 08:15 PM   [ Ignore ]   [ # 6 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  833
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 

All CodeIgniter resources into one place?
http://www.codeigniterdirectory.com

Buildon.net - The PHP Frameworks Showcase - Add your links!
http://www.buildon.net

My website: Création de sites Genève, Too Pixel

Profile
 
 
Posted: 19 March 2008 08: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
 Signature 

Devil with Mac
Gin2[Kronika]

Profile
 
 
Posted: 19 March 2008 08: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;

 Signature 

Devil with Mac
Gin2[Kronika]

Profile
 
 
Posted: 19 March 2008 08: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

 Signature 

Devil with Mac
Gin2[Kronika]

Profile
 
 
Posted: 31 March 2008 03:53 PM   [ Ignore ]   [ # 10 ]  
Summer Student
Total Posts:  30
Joined  12-12-2007

Can you please post your JS for us?

Profile
 
 
   
1 of 2
1
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 819, on March 11, 2010 11:15 AM
Total Registered Members: 120579 Total Logged-in Users: 22
Total Topics: 126616 Total Anonymous Users: 1
Total Replies: 665629 Total Guests: 333
Total Posts: 792245    
Members ( View Memberlist )