Jump to content


Multiple Grids in one page


  • Please log in to reply
2 replies to this topic

#1 flowerbed333

flowerbed333

    Newbie

  • Members
  • Pip
  • 5 posts

Posted 23 February 2018 - 01:04 PM

Hi,

 

I have purchased the Grocery Crud Enterprise to use multiple Grids ans now I cannot achieve my objective.

 

I am trying to make a Multiple Grids in on page based on example located at page https://www.groceryc...multiple-grids.

The code is simple but I am sure that someting is missing because noting happens. In your example in Code Igniter you have only 3 functions. All functions return something ... where happens the page generation ?

 

It's not possible to have a conroller with a multiple Grids sample like in the community version ?

Please Help me ...

I cannot achieve this ...

 

My code is 

 

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
 
include(APPPATH . 'libraries/GroceryCrudEnterprise/autoload.php');
use GroceryCrud\Core\GroceryCrud;
 
class Examples extends CI_Controller {
 
public function __construct()
{
parent::__construct();
 
$this->load->database();
$this->load->helper('url');
 
// You can simply remove these lines once you have base_url installed correctly
$config = [];
include(APPPATH . 'config/config.php');
if ($config['base_url'] === '') {
show_error('You forgot to application/config/config.php . For more check the video tutorial here: <a href="https://youtu.be/X0gnDD0qTS8?t=24s" target="_blank">Common mistakes when we install Grocery CRUD</a>');
}
 
// In case you will need grocery CRUD community edition, just
// uncomment the below line :)
// $this->load->library('grocery_CRUD');   
}
 
public function _example_output($output = null)
{
if (isset($output->isJSONResponse) && $output->isJSONResponse) {
            header('Content-Type: application/json; charset=utf-8');
            echo $output->output;
            exit;
}
 
$this->load->view('example.php',(array)$output);
}
 
public function index()
{
$this->_example_output((object)array('output' => '' , 'js_files' => array() , 'css_files' => array()));
}
 
public function customers_management()
{
$crud = $this->_getGroceryCrudEnterprise();
 
$crud->setTable('customers');
$crud->setSubject('Customer', 'Customers');
$crud->columns(['customerName','contactLastName','phone','city','country','salesRepEmployeeNumber','creditLimit']);
$crud->displayAs('salesRepEmployeeNumber','from Employeer')
->displayAs('customerName','Name')
->displayAs('contactLastName','Last Name');
$crud->setRelation('salesRepEmployeeNumber','employees','lastName');
 
$output = $crud->render();
 
$this->_example_output($output);
}
 
private function _getDbData() {
        $db = [];
        include(APPPATH . 'config/database.php');
        return [
            'adapter' => [
                'driver' => 'Pdo_Mysql',
                'host'     => $db['default']['hostname'],
                'database' => $db['default']['database'],
                'username' => $db['default']['username'],
                'password' => $db['default']['password'],
                'charset' => 'utf8'
            ]
        ];
    }
 
private function _getGroceryCrudEnterprise($bootstrap = true, $jquery = true) {
        $db = $this->_getDbData();
        $config = include(APPPATH . 'config/gcrud-enteprise.php');
        $groceryCrud = new GroceryCrud($config, $db);
        return $groceryCrud;
}
 
public function demo_multigrid() {
    $crud = $this->_getGroceryCrudEnterprise();
 
    $crud->setApiUrlPath('/EBO/index.php/examples/demo_example_films');
    $output = $crud->render();
 
    $crud2 = $this->_getGroceryCrudEnterprise();
 
    $crud2->setApiUrlPath('/EBO/index.php/examples/demo_example_customers');
    $output2 = $crud->render();
 
    $output->output .= '
' . $output2->output;
 
    $this->_example_output($output);
}
 
public function demo_example_films() {
    $crud = $this->_getGroceryCrudEnterprise();
 
    $crud->setTable('film');
    $crud->setSubject('Film', 'Films');
    $crud->setRead();
    $crud->setRelationNtoN('actors', 'film_actor', 'actor', 'film_id', 'actor_id', 'fullname');
    $crud->setRelationNtoN('categories', 'film_category', 'category', 'film_id', 'category_id', 'name');
 
    return $crud->render();
}
 
public function demo_example_customers() {
    $crud = $this->_getGroceryCrudEnterprise();
 
    $crud->setTable('customers');
    $crud->setSubject('Customer', 'Customers');
    $crud->setRead();
 
    return $crud->render();
}
}
 

Thx.

 

Mitch



#2 prbdcw

prbdcw

    Newbie

  • Members
  • Pip
  • 2 posts

Posted 12 April 2018 - 09:49 AM

Hi flowerbed333, did you find a solution for this issue. I also can't get multiple grids on one page using codeigniter and the sample provided: https://www.groceryc...multiple-grids.



#3 web-johnny

web-johnny

    grocery CRUD Author

  • Administrators
  • 1,155 posts
  • LocationLondon

Posted 12 April 2018 - 07:14 PM

Hello @flowerbed333,

 

the mistake here is that instead of 

return $crud->render();

 you should have: 

 $this->_example_output($output);

I did also update the documentation so it can reflect that.

 

If you just copy the code that exists at: https://www.groceryc.../multiple-grids then you should have the results that you want.

 

Please let me know if that worked for you or you still have issues and if you can also provide us a screenshot of what you see as a result.

 

Regards

Johnny


Posted Image




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users