Reference: Marius answer
In the layout xml file, change the Core Grid block to Custom Grid Block
like below:
<block class="Magento\Backend\Block\Widget\Grid" name="apptha_merchant_post_grid.grid" as="grid">
Change this to:
<block class="Apptha\Customergroup\Block\Adminhtml\Response" name="apptha_merchant_post_grid.grid" as="grid">
Code of the Block File is:
<?php
namespace Apptha\Customergroup\Block\Adminhtml;
class Response extends \Magento\Backend\Block\Widget\Grid
{
public function _construct()
{
parent::_construct();
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$referenceId = $objectManager->create('Apptha\Customergroup\Model\Deal')
->load($this->getRequest()->getParam('id'))->getData("reference_id");
//We'll get the Grid collection here by using this: $this->getCollection()
//We can filter it like addFieldToFilter method
//Here I am filtering grid collection using reference id
$this->getCollection()->addFieldToFilter('reference_id', array('eq' => $referenceId));
}
}