Export to csv showing undefined index UiComponentFactory.php
-
14-04-2021 - |
Domanda
I have used the below code in view :
<exportButton name="export_button">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="selectProvider" xsi:type="string">pos_outlet_listing.pos_outlet_listing.pos_outlet_columns.ids</item>
</item>
</argument>
</exportButton>
Got Error:
Notice: Undefined index: attributes in /home/yaboow/public_html/demo/vendor/magento/framework/View/Element/UiComponentFactory.php on line 176
version 2.3
Is there anything i have missed!!?
Soluzione
<!-- <selectionsColumn name="ids"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> <item name="resizeEnabled" xsi:type="boolean">false</item> <item name="resizeDefaultWidth" xsi:type="string">55</item> <item name="indexField" xsi:type="string">id</item> </item> </argument> </selectionsColumn> -->
You just need to remove comment form above code. Because UiComponentFactory.php take Data of array from it and pass this data to it's parent
public function __construct(
ObjectManagerInterface $objectManager,
ManagerInterface $componentManager,
InterpreterInterface $argumentInterpreter,
ContextFactory $contextFactory,
array $data = [],
array $componentChildFactories = [],
DataInterface $definitionData = null,
DataInterfaceFactory $configFactory = null
) {
$this->objectManager = $objectManager;
$this->componentManager = $componentManager;
$this->argumentInterpreter = $argumentInterpreter;
$this->contextFactory = $contextFactory;
$this->componentChildFactories = $componentChildFactories;
$this->configFactory = $configFactory ?: $this->objectManager->get(DataInterfaceFactory::class);
parent::__construct($data);
$this->definitionData = $definitionData ?:
$this->objectManager->get(DataInterface::class);
}
And it's parent class
Magento\Framework\DataObject
data set in SetData function
Altri suggerimenti
Check if yo have selection columns, if not add this
<selectionsColumn name="ids">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="resizeEnabled" xsi:type="boolean">false</item>
<item name="resizeDefaultWidth" xsi:type="string">55</item>
<item name="indexField" xsi:type="string">id</item>
</item>
</argument>
</selectionsColumn>
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a magento.stackexchange