Menu Close
    Hire us Request quote Reading list Switch to dark mode

    Add Column in existing grid in magento2

    To add a column in existing grid in magento2, you can follow following process:

    Firstly, create ui_component xml file with the same name which is used in existing grid.

    /app/code/Webkul/Test/view/adminhtml/ui_component/add_column_example.xml


    Here,
    Field “name” of <columns> tag should be same which used be existing grid.
    Field “class” of <column> tag contains class name in which we define the values for that column.
    Field “label” of <item> tag used for column name which you want to display on heading.
    Field “sortOrder” of <item> tag used for sort number for field.

    Now, create app/code/Webkul/Test/Ui/Component/Listing/Column/ShowAttrAction.php


    Here, $dataSource returns the array which includes values for your field.
    $this->getData(‘name’) is the value which you passed in name field of <column> tag.

    After this, your column is visible in grid.

    Thank you.

    . . .

    Comment

    Add Your Comment

    Be the first to comment.

    Back to Top
    css.php
    Hire Us!
    Brief us about your requirements and we'll get back to you.
    Woo! Hooy!
    We have just received your message and our expert will get back to you shortly.
    Send Again
    Close