I have UI form with a Block grid.
<fieldset name="profile_products">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="label" xsi:type="string" translate="true">Products</item>
<item name="collapsible" xsi:type="boolean">true</item>
</item>
</argument>
<field name="in_profile_products">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="visible" xsi:type="boolean">false</item>
<item name="dataType" xsi:type="string">text</item>
<item name="formElement" xsi:type="string">input</item>
<item name="source" xsi:type="string">amazon_profile_form_data_source</item>
<item name="label" xsi:type="string" translate="true">Selected Products</item>
</item>
</argument>
</field>
<container name="profile_products_container_grid">
<htmlContent name="html_content">
<argument name="block" xsi:type="object">MyVendor\MyModule\Block\Adminhtml\Profile\Ui\Form\Product</argument>
</htmlContent>
</container>
</fieldset>
namespace MyVendor\MyModule\Block\Adminhtml\Profile\Ui\Form;
class Product extends \Magento\Backend\Block\Template
{
/**
* Block template
*
* @var string
*/
protected $_template = 'MyVendor_MyModule::profile/product.phtml';
/**
* @var \Magento\Catalog\Block\Adminhtml\Category\Tab\Product
*/
protected $blockGrid;
/**
* Retrieve instance of grid block
*
* @return \Magento\Framework\View\Element\BlockInterface
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function getBlockGrid()
{
if (null === $this->blockGrid) {
$this->blockGrid = $this->getLayout()->createBlock(
\MyVendor\MyModule\Block\Adminhtml\Profile\Ui\Form\Product\Grid::class,
'mymodule.admin.profile.product.grid'
);
}
return $this->blockGrid;
}
}
Grid.php
namespace MyVendor\MyModule\Block\Adminhtml\Profile\Ui\Form\Product;
class Grid extends \Magento\Backend\Block\Widget\Grid\Extended
{ .....
}
products.phtml
$block->getGridHtml()
For reference: Link
I need to add a mass-action bar and select-all option in selection checkbox.