Advertisement
dropbox1349

flexigrid.php - controller - codeigniter

Feb 12th, 2015
604
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.69 KB | None | 0 0
  1. <?php
  2. class Flexigrid extends Controller {
  3.  
  4.     function Flexigrid  ()
  5.     {
  6.         parent::Controller();  
  7.         $this->load->helper('flexigrid');
  8.     }
  9.    
  10.     function index()
  11.     {
  12.         //ver lib
  13.        
  14.         // $this->load->model('ajax_model');
  15. // $records = $this->ajax_model->get_select_countries();
  16. // $options is result set, generate from database
  17. $options = Array (
  18.  Array ( 'code' => 'AFG', 'name' => 'AFG' ),
  19.  Array ( 'code' => 'DZA', 'name' => 'DZA' ),
  20.  Array ( 'code' => 'ASM', 'name' => 'ASM' ),
  21.  Array ( 'code' => 'AND', 'name' => 'AND' ),
  22.  Array ( 'code' => 'AGO', 'name' => 'AGO' )
  23. );
  24.  
  25. // create select option string format
  26. foreach( $records as $v ) {
  27.  $options .= $v['code'] .':'. $v['name'] . ';';
  28. }
  29. $options = substr($options, 0, -1);
  30.  
  31. /*
  32.  * 0 - display name
  33.  * 1 - width
  34.  * 2 - sortable
  35.  * 3 - align
  36.  * 4 - searchable (2 -> yes and default, 1 -> yes, 0 -> no.)
  37.  * 5 - option for search type and select option (type = text, date, select, default type is text)
  38.  */
  39. $colModel['id'] = array('ID',40,TRUE,'center',2);
  40. $colModel['iso'] = array('ISO',40,TRUE,'center',0);
  41. $colModel['name'] = array('Name',180,TRUE,'left',1);
  42. $colModel['printable_name'] = array('Printable Name',120,TRUE,'left',1,'options' => array('type' => 'date'));
  43. $colModel['iso3'] = array('ISO3',130, TRUE,'left',1, 'options' => array('type' => 'select', 'edit_options' => $options));
  44. $colModel['numcode'] = array('Number Code',80, TRUE, 'right',1, 'options' => array('type' => 'select', 'edit_options' => ":All;AND:AND;KK:KK;RE:RE"));
  45. $colModel['actions'] = array('Actions',80, FALSE, 'right',0);
  46.        
  47.         /*
  48.          * Aditional Parameters
  49.          */
  50.         $gridParams = array(
  51.         'width' => 'auto',
  52.         'height' => 400,
  53.         'rp' => 15,
  54.         'rpOptions' => '[10,15,20,25,40]',
  55.         'pagestat' => 'Displaying: {from} to {to} of {total} items.',
  56.         'blockOpacity' => 0.5,
  57.         'title' => 'Hello',
  58.         'showTableToggleBtn' => true
  59.         );
  60.        
  61.         /*
  62.          * 0 - display name
  63.          * 1 - bclass
  64.          * 2 - onpress
  65.          */
  66.         $buttons[] = array('Delete','delete','test');
  67.         $buttons[] = array('separator');
  68.         $buttons[] = array('Select All','add','test');
  69.         $buttons[] = array('DeSelect All','delete','test');
  70.         $buttons[] = array('separator');
  71.  
  72.        
  73.         //Build js
  74.         //View helpers/flexigrid_helper.php for more information about the params on this function
  75.         $grid_js = build_grid_js('flex1',site_url("/ajax"),$colModel,'id','asc',$gridParams,$buttons);
  76.        
  77.         $data['js_grid'] = $grid_js;
  78.         $data['version'] = "0.36";
  79.         $data['download_file'] = "Flexigrid_CI_v0.36.rar";
  80.        
  81.         $this->load->view('flexigrid',$data);
  82.     }
  83.    
  84.     function example ()
  85.     {
  86.         $data['version'] = "0.36";
  87.         $data['download_file'] = "Flexigrid_CI_v0.36.rar";
  88.        
  89.         $this->load->view('example',$data);
  90.     }
  91. }
  92. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement