I am assuming that your supplier's contact listing UI component file name is supplier_contacts_listing.xml
So in supplier_listing.xml, we import supplier_id from the current data source and pass it to the contact's grid source as a parameter.
<insertListing name="supplier_contacts">
<settings>
<dataLinks>
<exports>false</exports>
<imports>true</imports>
</dataLinks>
<autoRender>true</autoRender>
<selectionsProvider>supplier_contacts_listing.supplier_contacts_listing.columns.ids</selectionsProvider>
<externalProvider>supplier_contacts_listing.supplier_contacts_listing_data_source</externalProvider>
<dataScope>supplier_contacts_listing</dataScope>
<ns>supplier_contacts_listing</ns>
<exports>
<link name="supplier_id">${ $.externalProvider }:params.supplier_id</link>
</exports>
<imports>
<link name="supplier_id">${ $.provider}:data.supplier_id</link>
</imports>
</settings>
</insertListing>
In di.xml define a class for contact's data provider.
<type name="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory">
<arguments>
<argument name="collections" xsi:type="array">
<item name="supplier_contacts_listing.supplier_contacts_listing_data_source" xsi:type="string">Vendor\Module\Model\ResourceModel\Contacts\Grid\Collection</item>
</argument>
</arguments>
</type>
Finally in Collection.php
namespace Vendor\Module\Model\ResourceModel\Contacts\Grid;
class Collection extends \Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult
{
/**
* @var ContextInterface
*/
private $context;
/**
* ApplicableFilter constructor.
* @param ContextInterface $context
* @param \Magento\Framework\Data\Collection\EntityFactoryInterface $entityFactory
* @param \Psr\Log\LoggerInterface $logger
* @param \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy
* @param \Magento\Framework\Event\ManagerInterface $eventManager
* @param string $mainTable
* @param string $resourceModel
* @param string $identifierName
* @param null $connectionName
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function __construct(
\Magento\Framework\View\Element\UiComponent\ContextInterface $context,
\Magento\Framework\Data\Collection\EntityFactoryInterface $entityFactory,
\Psr\Log\LoggerInterface $logger,
\Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy,
\Magento\Framework\Event\ManagerInterface $eventManager,
$mainTable = "supplier_contacts",
$resourceModel = "\Vendor\Module\Model\ResourceModel\Contacts",
$identifierName = "entity_id",
$connectionName = null
) {
$this->context = $context;
parent::__construct(
$entityFactory,
$logger,
$fetchStrategy,
$eventManager,
$mainTable,
$resourceModel,
$identifierName,
$connectionName
);
}
protected function _initSelect()
{
parent::_initSelect();
$supplier_id = $this->context->getRequestParam("supplier_id");
if ($supplier_id) {
$this->addFieldToFilter("supplier_id", $supplier_id);
}
return $this;
}
}