I have been struggling with this for a couple days now... I have created a module that add a new tab to the customer admin page.
It works fine when loading and displaying the information I need but when I use the filters to find a product it reloads the whole tab instead of just the current grid overwriting the whole container.
In short I have 1 controller to generate the page from the following layout
Morello\Customerproducts\view\adminhtml\layout\customerproducts_index_customer.xml
<?xml version="1.0"?>
<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/layout_generic.xsd">
<container name="content" label="Root">
<block class="\Morello\Customproducts\Block\Adminhtml\Edit\Page\Frame" name="customer_product_edit_frame" template="Morello_Customproducts::frame.phtml">
<block class="\Morello\Customproducts\Block\Adminhtml\Edit\Page\CustomerProducts" template="Morello_Customproducts::products.phtml" name="customer_products">
<block class="\Morello\Customproducts\Block\Adminhtml\Edit\Page\CustomerProductsGrid" name="customer_products_grid" as="customer_products_grid" />
</block>
<block class="\Morello\Customproducts\Block\Adminhtml\Edit\Page\Search" template="Morello_Customproducts::search.phtml" name="customer_product_search">
<block class="\Morello\Customproducts\Block\Adminhtml\Edit\Page\SearchProductGrid" name="customer_product_search_grid" as="customer_product_search_grid" />
</block>
</block>
</container>
</layout>
As you can see I actually have 2 grids customer_products_grid
and customer_product_search_grid
for simplicity I will focus on the latter because I need to understand the process and I'll apply it to the former as well later on...
The grid module class file reference by \Morello\Customproducts\Block\Adminhtml\Edit\Page\SearchProductGrid
contains the following
Morello\Customerproducts\Block\Adminhtml\Edit\Page\SearchProduct.php
<?php
namespace Morello\Customproducts\Block\Adminhtml\Edit\Page;
use Magento\Backend\Block\Template\Context;
use Magento\Backend\Helper\Data;
use Magento\Backend\Model\Session\Quote;
use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory;
class SearchProductGrid extends \Magento\Backend\Block\Widget\Grid\Extended
{
private $productCollectionFactory;
private $sessionQuote;
public function __construct(
//...
)
{
//...
}
protected function _construct()
{
//..
}
public function getStore()
{
//...
}
public function getProductCollection()
{
//...
}
protected function _prepareCollection()
{
//...
}
protected function _prepareColumns()
{
//...
return parent::_prepareColumns();
}
/*************************************************************************/
// I KNOW I HAVE TO USE THIS TO GET WHAT I WANT BUT I CAN'T FIGURE OUT HOW
/*************************************************************************/
public function getGridUrl()
{
return $this->getUrl(
'customproducts/*/???', ['_current' => true, 'collapse' => null]
);
}
}
This is currently my ONLY controller
Morello\Customerproducts\Controller\Adminhtml\Index\Customer.php
class Customer extends \Magento\Customer\Controller\Adminhtml\Index
{
public function execute()
{
$this->initCurrentCustomer();
$resultLayout = $this->resultLayoutFactory->create();
return $resultLayout;
}
}
WHAT AM I MISSING?
Any help is appreciated, thanks guys.