Seems that we cannot use set_model in multigrid without having relation_n_n array mixed up.
I've successfully manage this with several error messages.
The error messages show that there is a problem with unloading a model with unset.
Do anybody know how to unload the model correctly?
public function new_crud(){ $db_driver = $this->db->platform(); $model_name = 'grocery_crud_model_'.$db_driver; unset($this->{$model_name}); $this->load->library('grocery_CRUD'); $crud = new Grocery_CRUD(); if (file_exists(APPPATH.'/models/'.$model_name.'.php')){ $this->load->model('grocery_crud_model'); $this->load->model('grocery_crud_generic_model'); $crud->set_model($model_name); } return $crud; } function multigrids() { $this->config->load('grocery_crud'); $this->config->set_item('grocery_crud_dialog_forms',true); $this->config->set_item('grocery_crud_default_per_page',10); $output1 = $this->offices_management2(); $output2 = $this->employees_management2(); $output3 = $this->customers_management2(); $js_files = $output1->js_files + $output2->js_files + $output3->js_files; $css_files = $output1->css_files + $output2->css_files + $output3->css_files; $output = "<h1>List 1</h1>".$output1->output."<h1>List 2</h1>".$output2->output."<h1>List 3</h1>".$output3->output; $this->_example_output((object)array( 'js_files' => $js_files, 'css_files' => $css_files, 'output' => $output )); } public function offices_management2() { $crud = $this->new_crud(); $crud->set_table('offices'); $crud->set_subject('Office'); $crud->set_crud_url_path(site_url(strtolower(__CLASS__."/".__FUNCTION__)),site_url(strtolower(__CLASS__."/multigrids"))); $output = $crud->render(); if($crud->getState() != 'list') { $this->_example_output($output); } else { return $output; } } public function employees_management2() { $crud = $this->new_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'); $crud->set_field_upload('file_url','assets/uploads/files'); $crud->set_crud_url_path(site_url(strtolower(__CLASS__."/".__FUNCTION__)),site_url(strtolower(__CLASS__."/multigrids"))); $output = $crud->render(); if($crud->getState() != 'list') { $this->_example_output($output); } else { return $output; } } public function customers_management2() { $crud = $this->new_crud(); $crud->set_table('customers'); $crud->columns('customerName','contactLastName','phone','city','country','salesRepEmployeeNumber','creditLimit'); $crud->display_as('salesRepEmployeeNumber','from Employeer') ->display_as('customerName','Name') ->display_as('contactLastName','Last Name'); $crud->set_subject('Customer'); $crud->set_relation('salesRepEmployeeNumber','employees','lastName'); $crud->set_crud_url_path(site_url(strtolower(__CLASS__."/".__FUNCTION__)),site_url(strtolower(__CLASS__."/multigrids"))); $output = $crud->render(); if($crud->getState() != 'list') { $this->_example_output($output); } else { return $output; } }