addeye

Paging CI

Oct 12th, 2016
119
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     public function table()
  2.     {
  3.         $data=array('link_edit' => site_url('barang/brg/update/'));
  4.  
  5.         $text=$this->input->post('text');
  6.  
  7.         $jml = $this->model->getLikeData($text);
  8.         //pengaturan pagination
  9.         $config['base_url'] = base_url().'barang/brg/table/';
  10.         $config['total_rows'] = count($jml);
  11.         $config['per_page'] = 10;
  12.  
  13.         $config['full_tag_open'] = '<nav arial-label="Page navigation"><ul class="pagination" style="margin-top:0px">';
  14.         $config['full_tag_close'] = '</ul></nav>';
  15.  
  16.         $config['first_link'] = 'First';
  17.         $config['first_tag_open'] = '<li>';
  18.         $config['first_tag_close'] = '</li>';
  19.  
  20.         $config['last_link'] = 'Last';
  21.         $config['last_tag_open'] = '<li>';
  22.         $config['last_tag_close'] = '</li>';
  23.  
  24.         $config['next_link'] = 'Next';
  25.         $config['next_tag_open'] = '<li>';
  26.         $config['next_tag_close'] = '</li>';
  27.  
  28.         $config['prev_link'] = 'Prev';
  29.         $config['prev_tag_open'] = '<li>';
  30.         $config['prev_tag_close'] = '</li>';
  31.  
  32.         $config['cur_tag_open'] = '<li class="active"><a>';
  33.         $config['cur_tag_close'] = '</a></li>';
  34.  
  35.         $config['num_tag_open'] = '<li>';
  36.         $config['num_tag_close'] = '</li>';
  37.  
  38.         $config['anchor_class'] = 'follow_link';
  39.         $config['attributes'] = array('onclick' => 'javascript:ajax_paging(this.href);return false;');
  40.         $from = ($this->uri->segment(4)) ? $this->uri->segment(4) : null;
  41.  
  42.         //inisialisasi config
  43.         $this->pagination->initialize($config);
  44.  
  45.         //buat pagination
  46.         $data['halaman'] = $this->pagination->create_links();
  47.  
  48.         //tamplikan data
  49.         $data['barang'] = $this->model->getPaggingData($config['per_page'],$from,$text);
  50.  
  51.         foreach($data['barang'] as $key=>$row)
  52.         {
  53.             $data['barang'][$key]->harga_beli = rupiah($row->buy_price);
  54.             $data['barang'][$key]->harga_jual = rupiah($row->sale_price);
  55.         }
  56.         $data['all'] = count($jml);
  57.  
  58.         $this->load->view('table',$data);
  59.     }
RAW Paste Data