How to add new column in custom table and also in admin listing page?
-
22-01-2021 - |
Solution
In
view/adminhtml/ui_component/listing.xml
Add this code to create new column.
<column name="name">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">text</item>
<item name="editor" xsi:type="array">
<item name="editorType" xsi:type="string">text</item>
</item>
<item name="label" xsi:type="string" translate="true">Name</item>
<item name="visible" xsi:type="boolean">false</item>
</item>
</argument>
</column>
Also, the name of the column must be the same as the database column field. So it will automatically retrieve data from the database.
The same Thing goes for Editing page. Add the Same Column in Edit form. if you want to create a field in existing database, you need to run UpgradeScheme script for this. https://magento.stackexchange.com/a/238655/66990
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange