在 magento 管理网格中默认预选所有行

Getting all rows pre-selected by default in magento admin grid

我在 magento 管理网格中的页面加载时默认预select所有行。

因此,当我 select 字段并应用批量操作时出现错误,即 'Please select items.'

供参考,请在下面找到快照:

所有字段 selected :

仍然出现错误:

如有任何帮助,我们将不胜感激..

您可以通过编写以下代码使其与 jquery 一起使用:

jQuery('a:contains("Select All")').click();

在要自动选择网格中所有项目的页面中的文档准备就绪中。

我发现了问题。

我在群发字段中设置了错误的名称。一旦我用列的正确索引名称替换它,问题就解决了。

代码片段如下:

parent::_prepareMassaction();
$this->setMassactionIdField('entity_id');
$this->setMassactionIdFilter('entity_id');
$this->setMassactionIdFieldOnlyIndexValue(true);
$this->getMassactionBlock()->setFormFieldName('sellers');