I've created a mass action for my custom grid. i've encountered a weird problem which is when i check all the checkboxes, it won't send any post id data when i try to retrieve it with:
$this->getRequest->getParams();
but when i don't check all of them, it will send all the data that has been checked, here's my mass action code in xml:
<massaction name="listing_massaction">
<action name="test">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="type" xsi:type="string">test</item>
<item name="label" xsi:type="string" translate="true">Test</item>
<item name="url" xsi:type="url" path="namespace_module/test/massTest"/>
</item>
</argument>
</action>
</massaction>
MassTest.php:
use Magento\Backend\App\Action\Context;
use Magento\Ui\Component\MassAction\Filter;
use Magento\Framework\Controller\ResultFactory;
use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection;
class MassTest extends \Magento\Backend\App\Action
{
public function __construct(
Context $context,
Filter $filter,
\Namespace\Module\Model\ResourceModel\Test\CollectionFactory $collectionFactory
) {
$this->filter = $filter;
$this->_listingProduct = $listingProduct;
$this->_collectionFactory = $collectionFactory;
parent::__construct($context, $filter);
}
public function execute(){
//$collection = $this->filter->getCollection($this->_collectionFactory->create()); // get your selected collection
//$collectionSize = $collection->getSize();
//echo $collectionSize;
$data = $this->getRequest()->getParams();
print_r($data['selected']);
exit;
}
/**
* @param AbstractCollection $collection
* @return \Magento\Backend\Model\View\Result\Redirect
*/
protected function massAction(AbstractCollection $collection)
{
}
}