⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Laravel Multiple Grids in View



orcuncolakoglu

orcuncolakoglu
  • profile picture
  • Member

Posted 19 June 2019 - 13:39 PM

Hello all,

 

Does anyone has a guide for loading multiple grids in same view for Laravel?

As the lack of documentation for an enterprise product, I am not able to sort it out for Laravel.

 

Thanks


web-johnny

web-johnny
  • profile picture
  • Administrator
  • 1,166 posts

Posted 22 June 2019 - 06:37 AM

Hello all,

 

Does anyone has a guide for loading multiple grids in same view for Laravel?

As the lack of documentation for an enterprise product, I am not able to sort it out for Laravel.

 

Thanks

 

Hello @orcuncolakoglu,

 

You can follow the same steps as per Codeigniter example. For example on Laravel if you've followed the instructions here for the installation: https://www.grocerycrud.com/enterprise/enterprise-documentation/laravel-installation your controller functions will look something like this:

 

   /**
     * Show the datagrid for customers
     *
     * @return \Illuminate\Http\Response
     */
    public function customers_management()
    {
        $crud = $this->_getGroceryCrudEnterprise();
        $crud->setTable('customers');
        $crud->setSubject('Customer', 'Customers');
        $output = $crud->render();
        return $this->_show_output($output);
    } 

and let's say you have also the below grid to be combined:

   /**
     * Show the datagrid for products
     *
     * @return \Illuminate\Http\Response
     */
    public function products_management()
    {
        $crud = $this->_getGroceryCrudEnterprise();
        $crud->setTable('products');
        $crud->setSubject('Product', 'Products');
        $output = $crud->render();
        return $this->_show_output($output);
    }

Make sure that customers_management and products_management are working fine on their own (e.g. as a standalone URL). So let's say that we have the URLs:

'/admin/customers_management' and '/admin/products_management' that are working as standalone URLs, your multigrid function should looksomething like this:
 

    /**
     * Show customers and products
     *
     * @return \Illuminate\Http\Response
     */
    public function demo_multigrid()
    {
       $crud->setApiUrlPath('/admin/customers_management');
       $output = $crud->render();
       
       $crud2 = $this->_getGroceryCrudEnterprise();
       
       $crud2->setApiUrlPath('/admin/products_management');
       $output2 = $crud->render();

       return $this->_show_output($output);
    }

Let me know if that worked for you

 

Regards

Johnny