I want to add a new column in my existing custom admin grid:

My columns in admin grid are:enter image description here

also I want this column to appear in edit listing page.

有帮助吗?

解决方案

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

许可以下: CC-BY-SA归因
scroll top