Sunday, January 5, 2014

Install Grocery pada Codeigniter

The installation is really easy. You just copy all the files to your project and you are ready to use grocery CRUD.

- load library grocery di __construct() pd Controller:
$this->load->library('grocery_CRUD');
 
- Buat fungsi di contoller untuk menampilkan table 
 public function employees()
    {
         $crud = new grocery_CRUD();
 
    $crud->set_theme('datatables');
    $crud->set_table('employees');
    $crud->set_relation('officeCode','offices','city');
    $crud->display_as('officeCode','Office City');
    $crud->set_subject('Employee');
 
    $crud->required_fields('lastName');
     $output = $crud->render();
 
        $this->_example_output($output);        
    }
 
    function _example_output($output = null)
 
    {
        $this->load->view('our_template.php',$output);    
    } 
 
 - Tambnahkan di View :
 - diantara head tag
<?php
foreach($css_files as $file): ?>
    <link type="text/css" rel="stylesheet" href="<?php echo $file; ?>" />

<?php endforeach; ?>
<?php foreach($js_files as $file): ?>

    <script src="<?php echo $file; ?>"></script>
<?php endforeach; ?>
- diantara Body tag :
  <?php echo $output; ?>

No comments:

Post a Comment