{"id":284323,"date":"2021-03-05T08:58:24","date_gmt":"2021-03-05T08:58:24","guid":{"rendered":"https:\/\/webkul.com\/blog\/?p=284323"},"modified":"2025-05-30T13:28:22","modified_gmt":"2025-05-30T13:28:22","slug":"magento-development-14-more-about-admin-grid","status":"publish","type":"post","link":"https:\/\/webkul.com\/blog\/magento-development-14-more-about-admin-grid\/","title":{"rendered":"Magento 2 Development 17: More about Admin Grid"},"content":{"rendered":"\n<p>In the previous blog, we created a very basic admin grid. Here we will modify it a little bit. <\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Class of a Column<\/h3>\n\n\n\n<p>In the previous grid, we have not shown the content of the blog. That is because the blog content will be large and it will not be practical to show the whole content. But we can show 20 characters just like we did on front-end. <\/p>\n\n\n\n<p>Let&#8217;s see how we can do that. We are adding a new column in the grid, so we need to change the content of the uiComponent file <em>view\/adminhtml\/ui_component\/blogmanager_blog_listing.xml<\/em><\/p>\n\n\n\n<p>Updated code for <em>view\/adminhtml\/ui_component\/blogmanager_blog_listing.xml<\/em> file<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;\n&lt;listing xmlns:xsi=&quot;http:\/\/www.w3.org\/2001\/XMLSchema-instance&quot; xsi:noNamespaceSchemaLocation=&quot;urn:magento:module:Magento_Ui:etc\/ui_configuration.xsd&quot;&gt;\n    &lt;argument name=&quot;data&quot; xsi:type=&quot;array&quot;&gt;\n        &lt;item name=&quot;js_config&quot; xsi:type=&quot;array&quot;&gt;\n            &lt;item name=&quot;provider&quot; xsi:type=&quot;string&quot;&gt;blogmanager_blog_listing.blogmanager_blog_listing_data_source&lt;\/item&gt;\n            &lt;item name=&quot;deps&quot; xsi:type=&quot;string&quot;&gt;blogmanager_blog_listing.blogmanager_blog_listing_data_source&lt;\/item&gt;\n        &lt;\/item&gt;\n        &lt;item name=&quot;spinner&quot; xsi:type=&quot;string&quot;&gt;blogmanager_blog_columns&lt;\/item&gt;\n    &lt;\/argument&gt;\n    &lt;dataSource name=&quot;blogmanager_blog_listing_data_source&quot;&gt;\n        &lt;argument name=&quot;dataProvider&quot; xsi:type=&quot;configurableObject&quot;&gt;\n            &lt;argument name=&quot;class&quot; xsi:type=&quot;string&quot;&gt;Magento\\Framework\\View\\Element\\UiComponent\\DataProvider\\DataProvider&lt;\/argument&gt;\n            &lt;argument name=&quot;name&quot; xsi:type=&quot;string&quot;&gt;blogmanager_blog_listing_data_source&lt;\/argument&gt;\n            &lt;argument name=&quot;primaryFieldName&quot; xsi:type=&quot;string&quot;&gt;entity_id&lt;\/argument&gt;\n            &lt;argument name=&quot;requestFieldName&quot; xsi:type=&quot;string&quot;&gt;entity_id&lt;\/argument&gt;\n            &lt;argument name=&quot;data&quot; xsi:type=&quot;array&quot;&gt;\n                &lt;item name=&quot;config&quot; xsi:type=&quot;array&quot;&gt;\n                &lt;item name=&quot;update_url&quot; xsi:type=&quot;url&quot; path=&quot;mui\/index\/render&quot;\/&gt;\n                &lt;item name=&quot;storageConfig&quot; xsi:type=&quot;array&quot;&gt;\n                    &lt;item name=&quot;indexField&quot; xsi:type=&quot;string&quot;&gt;entity_id&lt;\/item&gt;\n                &lt;\/item&gt;\n                &lt;\/item&gt;\n            &lt;\/argument&gt;\n        &lt;\/argument&gt;\n        &lt;argument name=&quot;data&quot; xsi:type=&quot;array&quot;&gt;\n            &lt;item name=&quot;js_config&quot; xsi:type=&quot;array&quot;&gt;\n                &lt;item name=&quot;component&quot; xsi:type=&quot;string&quot;&gt;Magento_Ui\/js\/grid\/provider&lt;\/item&gt;\n            &lt;\/item&gt;\n        &lt;\/argument&gt;\n    &lt;\/dataSource&gt;\n    &lt;listingToolbar name=&quot;listing_top&quot;&gt;\n        &lt;bookmark name=&quot;bookmarks&quot;\/&gt;\n        &lt;columnsControls name=&quot;columns_controls&quot;\/&gt;\n        &lt;filters name=&quot;listing_filters&quot;&gt;\n                &lt;argument name=&quot;data&quot; xsi:type=&quot;array&quot;&gt;\n                    &lt;item name=&quot;config&quot; xsi:type=&quot;array&quot;&gt;\n                        &lt;item name=&quot;templates&quot; xsi:type=&quot;array&quot;&gt;\n                            &lt;item name=&quot;filters&quot; xsi:type=&quot;array&quot;&gt;\n                                &lt;item name=&quot;select&quot; xsi:type=&quot;array&quot;&gt;\n                                    &lt;item name=&quot;component&quot; xsi:type=&quot;string&quot;&gt;Magento_Ui\/js\/form\/element\/ui-select&lt;\/item&gt;\n                                    &lt;item name=&quot;template&quot; xsi:type=&quot;string&quot;&gt;ui\/grid\/filters\/elements\/ui-select&lt;\/item&gt;\n                                &lt;\/item&gt;\n                            &lt;\/item&gt;\n                        &lt;\/item&gt;\n                    &lt;\/item&gt;\n                &lt;\/argument&gt;\n        &lt;\/filters&gt;\n        &lt;paging name=&quot;listing_paging&quot;\/&gt;\n    &lt;\/listingToolbar&gt;\n    &lt;columns name=&quot;blogmanager_blog_columns&quot;&gt;\n        &lt;column name=&quot;entity_id&quot;&gt;\n            &lt;settings&gt;\n                &lt;filter&gt;textRange&lt;\/filter&gt;\n                &lt;label translate=&quot;true&quot;&gt;ID&lt;\/label&gt;\n                &lt;resizeDefaultWidth&gt;25&lt;\/resizeDefaultWidth&gt;\n            &lt;\/settings&gt;\n        &lt;\/column&gt;\n        &lt;column name=&quot;user_id&quot;&gt;\n            &lt;settings&gt;\n                &lt;filter&gt;text&lt;\/filter&gt;\n                &lt;label translate=&quot;true&quot;&gt;User&lt;\/label&gt;\n            &lt;\/settings&gt;\n        &lt;\/column&gt;\n        &lt;column name=&quot;title&quot;&gt;\n            &lt;settings&gt;\n                &lt;filter&gt;text&lt;\/filter&gt;\n                &lt;label translate=&quot;true&quot;&gt;Title&lt;\/label&gt;\n            &lt;\/settings&gt;\n        &lt;\/column&gt;\n        &lt;column name=&quot;content&quot; class=&quot;Webkul\\BlogManager\\Ui\\Component\\Listing\\Columns\\Content&quot;&gt;\n            &lt;settings&gt;\n                &lt;filter&gt;false&lt;\/filter&gt;\n                &lt;sortable&gt;false&lt;\/sortable&gt;\n                &lt;label translate=&quot;true&quot;&gt;Content&lt;\/label&gt;\n            &lt;\/settings&gt;\n        &lt;\/column&gt;\n        &lt;column name=&quot;status&quot;&gt;\n            &lt;settings&gt;\n                &lt;filter&gt;text&lt;\/filter&gt;\n                &lt;sortable&gt;false&lt;\/sortable&gt;\n                &lt;label translate=&quot;true&quot;&gt;Status&lt;\/label&gt;\n            &lt;\/settings&gt;\n        &lt;\/column&gt;\n        &lt;column name=&quot;updated_at&quot; component=&quot;Magento_Ui\/js\/grid\/columns\/date&quot;&gt;\n            &lt;settings&gt;\n                &lt;filter&gt;dateRange&lt;\/filter&gt;\n                &lt;dataType&gt;date&lt;\/dataType&gt;\n                &lt;label translate=&quot;true&quot;&gt;Updated&lt;\/label&gt;\n            &lt;\/settings&gt;\n        &lt;\/column&gt;\n        &lt;column name=&quot;created_at&quot; component=&quot;Magento_Ui\/js\/grid\/columns\/date&quot;&gt;\n            &lt;settings&gt;\n                &lt;filter&gt;dateRange&lt;\/filter&gt;\n                &lt;dataType&gt;date&lt;\/dataType&gt;\n                &lt;label translate=&quot;true&quot;&gt;Created&lt;\/label&gt;\n            &lt;\/settings&gt;\n        &lt;\/column&gt;\n    &lt;\/columns&gt;\n&lt;\/listing&gt;<\/pre>\n\n\n\n<p>Please use the <a href=\"https:\/\/www.google.com\/search?q=online+diff+checker\">online diff checker<\/a> to easily see what&#8217;s different from the last version of this file. The only thing different here is that we have added a new column tag for content. In that tag, we have used class=&#8221;Webkul\\BlogManager\\Ui\\Component\\Listing\\Columns\\Content&#8221;. By adding the class we are telling Magento that we will provide the data for this column with this class. All the UI component-related php files are created under <em><em>Ui\/Component<\/em><\/em> folder.<\/p>\n\n\n\n<p>Now let&#8217;s create the Content class as <em>Ui\/Component\/Listing\/Columns\/Content.php<\/em><\/p>\n\n\n\n<p>Code for <em>Ui\/Component\/Listing\/Columns\/Content.php<\/em> file<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php\nnamespace Webkul\\BlogManager\\Ui\\Component\\Listing\\Columns;\n\nclass Content extends \\Magento\\Ui\\Component\\Listing\\Columns\\Column\n{\n    \/**\n     * Prepare Data Source\n     *\n     * @param array $dataSource\n     * @return array\n     *\/\n    public function prepareDataSource(array $dataSource)\n    {\n        if (isset($dataSource&#091;&#039;data&#039;]&#091;&#039;items&#039;])) {\n            $fieldName = &#039;content&#039;;\n            foreach ($dataSource&#091;&#039;data&#039;]&#091;&#039;items&#039;] as &amp;$item) {\n                $item&#091;$fieldName] = substr($item&#091;$fieldName], 0, 20).&#039;...&#039;;\n            }\n        }\n        return $dataSource;\n    }\n}<\/pre>\n\n\n\n<p>So what we are doing here is that we are looping through all the rows and updating the <em>content<\/em> column to show only 20 characters. For updating the data, we are using the <em>prepareDataSource<\/em> method.<\/p>\n\n\n\n<p>We use this technique when we need to perform some operations before showing the data or when the data is not coming from our table.<\/p>\n\n\n\n<p>Now if you browse, you will see the content column,<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1200\" height=\"414\" src=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/03\/2021-03-05_11-03-1200x414.png\" alt=\"2021-03-05_11-03\" class=\"wp-image-284460\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/03\/2021-03-05_11-03-1200x414.png 1200w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/03\/2021-03-05_11-03-300x103.png 300w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/03\/2021-03-05_11-03-250x86.png 250w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/03\/2021-03-05_11-03-768x265.png 768w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/03\/2021-03-05_11-03-1536x530.png 1536w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/03\/2021-03-05_11-03.png 1835w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" loading=\"lazy\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><br>Select Option type Column<\/h3>\n\n\n\n<p>We will be implementing a feature in the next few blogs with which the admin will be able to manage the status of the blog. That&#8217;s why we have added the status column, which will be 0 or 1. In the status column, we are showing 0 or 1 instead it will be better if we show text labels such as Disabled or Enabled.<\/p>\n\n\n\n<p>So for that as you may have guessed we need to make changes in <em>view\/adminhtml\/ui_component\/blogmanager_blog_listing.xml<\/em> <\/p>\n\n\n\n<p>Updated code for <em>view\/adminhtml\/ui_component\/blogmanager_blog_listing.xml<\/em> file<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;\n&lt;listing xmlns:xsi=&quot;http:\/\/www.w3.org\/2001\/XMLSchema-instance&quot; xsi:noNamespaceSchemaLocation=&quot;urn:magento:module:Magento_Ui:etc\/ui_configuration.xsd&quot;&gt;\n    &lt;argument name=&quot;data&quot; xsi:type=&quot;array&quot;&gt;\n        &lt;item name=&quot;js_config&quot; xsi:type=&quot;array&quot;&gt;\n            &lt;item name=&quot;provider&quot; xsi:type=&quot;string&quot;&gt;blogmanager_blog_listing.blogmanager_blog_listing_data_source&lt;\/item&gt;\n            &lt;item name=&quot;deps&quot; xsi:type=&quot;string&quot;&gt;blogmanager_blog_listing.blogmanager_blog_listing_data_source&lt;\/item&gt;\n        &lt;\/item&gt;\n        &lt;item name=&quot;spinner&quot; xsi:type=&quot;string&quot;&gt;blogmanager_blog_columns&lt;\/item&gt;\n    &lt;\/argument&gt;\n    &lt;dataSource name=&quot;blogmanager_blog_listing_data_source&quot;&gt;\n        &lt;argument name=&quot;dataProvider&quot; xsi:type=&quot;configurableObject&quot;&gt;\n            &lt;argument name=&quot;class&quot; xsi:type=&quot;string&quot;&gt;Magento\\Framework\\View\\Element\\UiComponent\\DataProvider\\DataProvider&lt;\/argument&gt;\n            &lt;argument name=&quot;name&quot; xsi:type=&quot;string&quot;&gt;blogmanager_blog_listing_data_source&lt;\/argument&gt;\n            &lt;argument name=&quot;primaryFieldName&quot; xsi:type=&quot;string&quot;&gt;entity_id&lt;\/argument&gt;\n            &lt;argument name=&quot;requestFieldName&quot; xsi:type=&quot;string&quot;&gt;entity_id&lt;\/argument&gt;\n            &lt;argument name=&quot;data&quot; xsi:type=&quot;array&quot;&gt;\n                &lt;item name=&quot;config&quot; xsi:type=&quot;array&quot;&gt;\n                &lt;item name=&quot;update_url&quot; xsi:type=&quot;url&quot; path=&quot;mui\/index\/render&quot;\/&gt;\n                &lt;item name=&quot;storageConfig&quot; xsi:type=&quot;array&quot;&gt;\n                    &lt;item name=&quot;indexField&quot; xsi:type=&quot;string&quot;&gt;entity_id&lt;\/item&gt;\n                &lt;\/item&gt;\n                &lt;\/item&gt;\n            &lt;\/argument&gt;\n        &lt;\/argument&gt;\n        &lt;argument name=&quot;data&quot; xsi:type=&quot;array&quot;&gt;\n            &lt;item name=&quot;js_config&quot; xsi:type=&quot;array&quot;&gt;\n                &lt;item name=&quot;component&quot; xsi:type=&quot;string&quot;&gt;Magento_Ui\/js\/grid\/provider&lt;\/item&gt;\n            &lt;\/item&gt;\n        &lt;\/argument&gt;\n    &lt;\/dataSource&gt;\n    &lt;listingToolbar name=&quot;listing_top&quot;&gt;\n        &lt;bookmark name=&quot;bookmarks&quot;\/&gt;\n        &lt;columnsControls name=&quot;columns_controls&quot;\/&gt;\n        &lt;filters name=&quot;listing_filters&quot;&gt;\n                &lt;argument name=&quot;data&quot; xsi:type=&quot;array&quot;&gt;\n                    &lt;item name=&quot;config&quot; xsi:type=&quot;array&quot;&gt;\n                        &lt;item name=&quot;templates&quot; xsi:type=&quot;array&quot;&gt;\n                            &lt;item name=&quot;filters&quot; xsi:type=&quot;array&quot;&gt;\n                                &lt;item name=&quot;select&quot; xsi:type=&quot;array&quot;&gt;\n                                    &lt;item name=&quot;component&quot; xsi:type=&quot;string&quot;&gt;Magento_Ui\/js\/form\/element\/ui-select&lt;\/item&gt;\n                                    &lt;item name=&quot;template&quot; xsi:type=&quot;string&quot;&gt;ui\/grid\/filters\/elements\/ui-select&lt;\/item&gt;\n                                &lt;\/item&gt;\n                            &lt;\/item&gt;\n                        &lt;\/item&gt;\n                    &lt;\/item&gt;\n                &lt;\/argument&gt;\n        &lt;\/filters&gt;\n        &lt;paging name=&quot;listing_paging&quot;\/&gt;\n    &lt;\/listingToolbar&gt;\n    &lt;columns name=&quot;blogmanager_blog_columns&quot;&gt;\n        &lt;column name=&quot;entity_id&quot;&gt;\n            &lt;settings&gt;\n                &lt;filter&gt;textRange&lt;\/filter&gt;\n                &lt;label translate=&quot;true&quot;&gt;ID&lt;\/label&gt;\n                &lt;resizeDefaultWidth&gt;25&lt;\/resizeDefaultWidth&gt;\n            &lt;\/settings&gt;\n        &lt;\/column&gt;\n        &lt;column name=&quot;user_id&quot;&gt;\n            &lt;settings&gt;\n                &lt;filter&gt;text&lt;\/filter&gt;\n                &lt;label translate=&quot;true&quot;&gt;User&lt;\/label&gt;\n            &lt;\/settings&gt;\n        &lt;\/column&gt;\n        &lt;column name=&quot;title&quot;&gt;\n            &lt;settings&gt;\n                &lt;filter&gt;text&lt;\/filter&gt;\n                &lt;label translate=&quot;true&quot;&gt;Title&lt;\/label&gt;\n            &lt;\/settings&gt;\n        &lt;\/column&gt;\n        &lt;column name=&quot;content&quot; class=&quot;Webkul\\BlogManager\\Ui\\Component\\Listing\\Columns\\Content&quot;&gt;\n            &lt;settings&gt;\n                &lt;filter&gt;false&lt;\/filter&gt;\n                &lt;sortable&gt;false&lt;\/sortable&gt;\n                &lt;label translate=&quot;true&quot;&gt;Content&lt;\/label&gt;\n            &lt;\/settings&gt;\n        &lt;\/column&gt;\n        &lt;column name=&quot;status&quot; component=&quot;Magento_Ui\/js\/grid\/columns\/select&quot;&gt;\n            &lt;settings&gt;\n                &lt;options class=&quot;Webkul\\BlogManager\\Model\\Blog\\Status&quot;\/&gt;\n                &lt;dataType&gt;select&lt;\/dataType&gt;\n                &lt;filter&gt;select&lt;\/filter&gt;\n                &lt;sortable&gt;false&lt;\/sortable&gt;\n                &lt;label translate=&quot;true&quot;&gt;Status&lt;\/label&gt;\n            &lt;\/settings&gt;\n        &lt;\/column&gt;\n        &lt;column name=&quot;updated_at&quot; component=&quot;Magento_Ui\/js\/grid\/columns\/date&quot;&gt;\n            &lt;settings&gt;\n                &lt;filter&gt;dateRange&lt;\/filter&gt;\n                &lt;dataType&gt;date&lt;\/dataType&gt;\n                &lt;label translate=&quot;true&quot;&gt;Updated&lt;\/label&gt;\n            &lt;\/settings&gt;\n        &lt;\/column&gt;\n        &lt;column name=&quot;created_at&quot; component=&quot;Magento_Ui\/js\/grid\/columns\/date&quot;&gt;\n            &lt;settings&gt;\n                &lt;filter&gt;dateRange&lt;\/filter&gt;\n                &lt;dataType&gt;date&lt;\/dataType&gt;\n                &lt;label translate=&quot;true&quot;&gt;Created&lt;\/label&gt;\n            &lt;\/settings&gt;\n        &lt;\/column&gt;\n    &lt;\/columns&gt;\n&lt;\/listing&gt;<\/pre>\n\n\n\n<p>Only changes you will find here are in the column tag. We are using a select component that will replace the value with the label. We will provide key-value pair with the options class <em>Webkul\\BlogManager\\Model\\Blog\\Status<\/em>. <\/p>\n\n\n\n<p>In an earlier section, I mentioned that all the PHP files related to the <a href=\"https:\/\/webkul.com\/blog\/how-to-create-a-grid-using-ui-component\/\">ui component<\/a> should be in Ui\/Component folder but this class is not limited to ui component, we can use it front-end too. So I will create it in the model folder (it&#8217;s a general convention).<\/p>\n\n\n\n<p>In the filter tag, we have mentioned that it is a select type so in the filter section you will find a multi-select dropdown for this column. <\/p>\n\n\n\n<p>Now let&#8217;s see the option class <em>Model\/Blog\/Status.php<\/em><\/p>\n\n\n\n<p>Code for <em>Model\/Blog\/Status.php<\/em> file<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php\nnamespace Webkul\\BlogManager\\Model\\Blog;\n\nuse Magento\\Framework\\Data\\OptionSourceInterface;\n\nclass Status implements OptionSourceInterface\n{\n    \/**\n     * Converts to option array\n     *\n     * @return array\n     *\/\n    public function toOptionArray()\n    {\n        $options = &#091;];\n        $options&#091;] = &#091;&#039;label&#039; =&gt; &#039;Disabled&#039;, &#039;value&#039; =&gt; 0];\n        $options&#091;] = &#091;&#039;label&#039; =&gt; &#039;Enabled&#039;, &#039;value&#039; =&gt; 1];\n        return $options;\n    }\n}<\/pre>\n\n\n\n<p>Here we are creating an associative array and returning it in the <em>toOptionArray<\/em> method.<\/p>\n\n\n\n<p>Whenever we have any such column which has options, like Yes\/No or Bad\/Neutral\/Good, etc. we use this technique.<\/p>\n\n\n\n<p>Now if you check the Manage Blog page, you will see the changes,<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1200\" height=\"570\" src=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/03\/2021-03-05_12-16-1200x570.png\" alt=\"2021-03-05_12-16\" class=\"wp-image-284478\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/03\/2021-03-05_12-16-1200x570.png 1200w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/03\/2021-03-05_12-16-300x142.png 300w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/03\/2021-03-05_12-16-250x119.png 250w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/03\/2021-03-05_12-16-768x365.png 768w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/03\/2021-03-05_12-16-1536x729.png 1536w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/03\/2021-03-05_12-16.png 1822w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" loading=\"lazy\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><br>_renderFiltersBefore<\/h3>\n\n\n\n<p>In the grid, we are showing the customer id in the User column which is not very helpful. Instead of the id, we should show the customer&#8217;s name. We can do this by creating a class for the column but then we will not be able to perform sorting and filtering on that column.<\/p>\n\n\n\n<p>This is because the column data get modified later. What I mean by this is that at first the original SQL query gets executed (in our virtual class) then we loop through the rows that we get as a result of the SQL query.<\/p>\n\n\n\n<p>So if we want sorting and filtering to work we need to modify the SQL, for that, we need to create the actual data provider class instead of using the virtual class.<\/p>\n\n\n\n<p>The customer data are stored in the &#8220;customer_grid_flat&#8221; table. We can join our table with the customer table to get the name. <\/p>\n\n\n\n<p>Now let&#8217;s see this in code. First, we will create the data provider class as <em>Model\/ResourceModel\/Blog\/Grid\/Collection.php<\/em> this is the general convention to create the data provider or grid collection of a table alongside the collection class of that table.<\/p>\n\n\n\n<p>Code for <em>Model\/ResourceModel\/Blog\/Grid\/Collection.php<\/em> file<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php\nnamespace Webkul\\BlogManager\\Model\\ResourceModel\\Blog\\Grid;\n\nuse Magento\\Framework\\Api\\Search\\SearchResultInterface;\nuse Magento\\Framework\\Search\\AggregationInterface;\nuse Webkul\\BlogManager\\Model\\ResourceModel\\Blog\\Collection as BlogCollection;\nuse Magento\\Framework\\Data\\Collection\\EntityFactoryInterface;\nuse Psr\\Log\\LoggerInterface;\nuse Magento\\Framework\\Data\\Collection\\Db\\FetchStrategyInterface;\nuse Magento\\Framework\\Event\\ManagerInterface;\nuse Magento\\Framework\\Model\\ResourceModel\\Db\\AbstractDb;\n\nclass Collection extends BlogCollection implements SearchResultInterface\n{\n    \/**\n     * Dependency Initilization\n     *\n     * @param EntityFactoryInterface $entityFactory\n     * @param LoggerInterface $logger\n     * @param FetchStrategyInterface $fetchStrategy\n     * @param ManagerInterface $eventManager\n     * @param &#091;type] $mainTable\n     * @param &#091;type] $resourceModel\n     * @param &#091;type] $model\n     * @param \\Magento\\Framework\\DB\\Adapter\\AdapterInterface|null $connection\n     * @param AbstractDb|null $resource\n     *\/\n    public function __construct(\n        EntityFactoryInterface $entityFactory,\n        LoggerInterface $logger,\n        FetchStrategyInterface $fetchStrategy,\n        ManagerInterface $eventManager,\n        $mainTable,\n        $resourceModel,\n        $model = \\Magento\\Framework\\View\\Element\\UiComponent\\DataProvider\\Document::class,\n        \\Magento\\Framework\\DB\\Adapter\\AdapterInterface $connection = null,\n        AbstractDb $resource = null\n    ) {\n        parent::__construct(\n            $entityFactory,\n            $logger,\n            $fetchStrategy,\n            $eventManager,\n            $connection,\n            $resource\n        );\n        $this-&gt;_init($model, $resourceModel);\n        $this-&gt;setMainTable($mainTable);\n    }\n\n    \/**\n     * Get Agrigations\n     *\n     * @return \\Magento\\Framework\\Api\\Search\\AggregationInterface\n     *\/\n    public function getAggregations()\n    {\n        return $this-&gt;aggregations;\n    }\n\n    \/**\n     * Set Agrigations\n     *\n     * @param \\Magento\\Framework\\Api\\Search\\AggregationInterface $aggregations $aggregations\n     * @return \\Magento\\Framework\\Api\\Search\\SearchResultInterface\n     *\/\n    public function setAggregations($aggregations)\n    {\n        $this-&gt;aggregations = $aggregations;\n    }\n\n    \/**\n     * Get Search Criteria\n     *\n     * @return null\n     *\/\n    public function getSearchCriteria()\n    {\n        return null;\n    }\n    \n    \/**\n     * Set Search Criteria\n     *\n     * @param \\Magento\\Framework\\Api\\SearchCriteriaInterface|null $searchCriteria\n     * @return this\n     *\/\n    public function setSearchCriteria(\n        \\Magento\\Framework\\Api\\SearchCriteriaInterface $searchCriteria = null\n    ) {\n        return $this;\n    }\n\n    \/**\n     * Returns the total count of the bolg\n     *\n     * @return int\n     *\/\n    public function getTotalCount()\n    {\n        return $this-&gt;getSize();\n    }\n\n    \/**\n     * Sets the total count of the bolg\n     *\n     * @param int $totalCount\n     * @return this\n     *\/\n    public function setTotalCount($totalCount)\n    {\n        return $this;\n    }\n\n    \/**\n     * Set Item\n     *\n     * @param array|null $items\n     * @return int\n     *\/\n    public function setItems(array $items = null)\n    {\n        return $this;\n    }\n\n    \/**\n     * Render Filter before\n     *\n     * @return void\n     *\/\n    protected function _renderFiltersBefore()\n    {\n        $cgfTable = $this-&gt;getTable(&#039;customer_grid_flat&#039;);\n        $this-&gt;getSelect()-&gt;joinLeft(\n            $cgfTable.&#039; as cgf&#039;,\n            &#039;main_table.user_id = cgf.entity_id&#039;,\n            &#091;\n                &#039;user_name&#039;=&gt;&#039;cgf.name&#039;\n            ]\n        );\n        parent::_renderFiltersBefore();\n    }\n    \n    \/**\n     * Initilize Select\n     *\n     * @return void\n     *\/\n    protected function _initSelect()\n    {\n        $this-&gt;addFilterToMap(&#039;user_name&#039;, &#039;cgf.name&#039;);\n        parent::_initSelect();\n    }\n}<\/pre>\n\n\n\n<p>You don&#8217;t have to worry about all the methods. We have to understand only <em>_renderFiltersBefore<\/em> and <em>_initSelect<\/em> methods. <\/p>\n\n\n\n<p><strong>$this-&gt;getTable(&#8216;customer_grid_flat&#8217;)<\/strong> This will give the table name by adding the table prefix if any.<\/p>\n\n\n\n<p>We already know about the <em>getSelect<\/em>, <strong>$this-&gt;getSelect()<\/strong> will give access to the SQL query of this class. We are performing left join with the <em>joinLeft<\/em> method. Then we are joining the <em>customer_grid_flat table on &#8216;main_table.user_id = cgf.entity_id&#8217;<\/em>, where <em>cgf <\/em>is an alias for <em>customer_grid_flat<\/em>. And we are getting the customer name in the <em><strong>user_name<\/strong><\/em> column.<\/p>\n\n\n\n<p>The actual SQL query will look like this,<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">SELECT\n   `main_table`.*,\n   `cgf`.`name` AS `user_name` \nFROM\n   `blogmanager_blog` AS `main_table` \n   LEFT JOIN\n      `customer_grid_flat` AS `cgf` \n      ON main_table.user_id = cgf.entity_id<\/pre>\n\n\n\n<p>We also need to map this column alias in the <em>_initSelect<\/em> method otherwise the filter will not work.<\/p>\n\n\n\n<p><br>Now we need to modify the <em>etc\/di.xml<\/em> because the data provider is not a virtual class anymore,<\/p>\n\n\n\n<p>Updated code for <em>etc\/di.xml<\/em> file<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?xml version=&quot;1.0&quot;?&gt;\n&lt;config xmlns:xsi=&quot;http:\/\/www.w3.org\/2001\/XMLSchema-instance&quot; xsi:noNamespaceSchemaLocation=&quot;urn:magento:framework:ObjectManager\/etc\/config.xsd&quot;&gt;\n    &lt;type name=&quot;Webkul\\BlogManager\\Model\\ResourceModel\\Blog\\Grid\\Collection&quot;&gt;\n        &lt;arguments&gt;\n            &lt;argument name=&quot;mainTable&quot; xsi:type=&quot;string&quot;&gt;blogmanager_blog&lt;\/argument&gt;\n            &lt;argument name=&quot;resourceModel&quot; xsi:type=&quot;string&quot;&gt;Webkul\\BlogManager\\Model\\ResourceModel\\Blog&lt;\/argument&gt;\n        &lt;\/arguments&gt;\n    &lt;\/type&gt;\n    &lt;type name=&quot;Magento\\Framework\\View\\Element\\UiComponent\\DataProvider\\CollectionFactory&quot;&gt;\n        &lt;arguments&gt;\n            &lt;argument name=&quot;collections&quot; xsi:type=&quot;array&quot;&gt;\n                &lt;item name=&quot;blogmanager_blog_listing_data_source&quot; xsi:type=&quot;string&quot;&gt;Webkul\\BlogManager\\Model\\ResourceModel\\Blog\\Grid\\Collection&lt;\/item&gt;\n            &lt;\/argument&gt;\n        &lt;\/arguments&gt;\n    &lt;\/type&gt;\n&lt;\/config&gt;<\/pre>\n\n\n\n<p>Here we have changed the tag virtualType to type. And we are providing the arguments as before. If you check the grid class you will find these arguments in the <strong>__construct<\/strong> method. <\/p>\n\n\n\n<p><br>We also need to change the ui component file <em>view\/adminhtml\/ui_component\/blogmanager_blog_listing.xml<\/em> because the new column name is <em>user_name<\/em><\/p>\n\n\n\n<p>Updated code for <em>view\/adminhtml\/ui_component\/blogmanager_blog_listing.xml<\/em> file<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;\n&lt;listing xmlns:xsi=&quot;http:\/\/www.w3.org\/2001\/XMLSchema-instance&quot; xsi:noNamespaceSchemaLocation=&quot;urn:magento:module:Magento_Ui:etc\/ui_configuration.xsd&quot;&gt;\n    &lt;argument name=&quot;data&quot; xsi:type=&quot;array&quot;&gt;\n        &lt;item name=&quot;js_config&quot; xsi:type=&quot;array&quot;&gt;\n            &lt;item name=&quot;provider&quot; xsi:type=&quot;string&quot;&gt;blogmanager_blog_listing.blogmanager_blog_listing_data_source&lt;\/item&gt;\n            &lt;item name=&quot;deps&quot; xsi:type=&quot;string&quot;&gt;blogmanager_blog_listing.blogmanager_blog_listing_data_source&lt;\/item&gt;\n        &lt;\/item&gt;\n        &lt;item name=&quot;spinner&quot; xsi:type=&quot;string&quot;&gt;blogmanager_blog_columns&lt;\/item&gt;\n    &lt;\/argument&gt;\n    &lt;dataSource name=&quot;blogmanager_blog_listing_data_source&quot;&gt;\n        &lt;argument name=&quot;dataProvider&quot; xsi:type=&quot;configurableObject&quot;&gt;\n            &lt;argument name=&quot;class&quot; xsi:type=&quot;string&quot;&gt;Magento\\Framework\\View\\Element\\UiComponent\\DataProvider\\DataProvider&lt;\/argument&gt;\n            &lt;argument name=&quot;name&quot; xsi:type=&quot;string&quot;&gt;blogmanager_blog_listing_data_source&lt;\/argument&gt;\n            &lt;argument name=&quot;primaryFieldName&quot; xsi:type=&quot;string&quot;&gt;entity_id&lt;\/argument&gt;\n            &lt;argument name=&quot;requestFieldName&quot; xsi:type=&quot;string&quot;&gt;entity_id&lt;\/argument&gt;\n            &lt;argument name=&quot;data&quot; xsi:type=&quot;array&quot;&gt;\n                &lt;item name=&quot;config&quot; xsi:type=&quot;array&quot;&gt;\n                &lt;item name=&quot;update_url&quot; xsi:type=&quot;url&quot; path=&quot;mui\/index\/render&quot;\/&gt;\n                &lt;item name=&quot;storageConfig&quot; xsi:type=&quot;array&quot;&gt;\n                    &lt;item name=&quot;indexField&quot; xsi:type=&quot;string&quot;&gt;entity_id&lt;\/item&gt;\n                &lt;\/item&gt;\n                &lt;\/item&gt;\n            &lt;\/argument&gt;\n        &lt;\/argument&gt;\n        &lt;argument name=&quot;data&quot; xsi:type=&quot;array&quot;&gt;\n            &lt;item name=&quot;js_config&quot; xsi:type=&quot;array&quot;&gt;\n                &lt;item name=&quot;component&quot; xsi:type=&quot;string&quot;&gt;Magento_Ui\/js\/grid\/provider&lt;\/item&gt;\n            &lt;\/item&gt;\n        &lt;\/argument&gt;\n    &lt;\/dataSource&gt;\n    &lt;listingToolbar name=&quot;listing_top&quot;&gt;\n        &lt;bookmark name=&quot;bookmarks&quot;\/&gt;\n        &lt;columnsControls name=&quot;columns_controls&quot;\/&gt;\n        &lt;filters name=&quot;listing_filters&quot;&gt;\n                &lt;argument name=&quot;data&quot; xsi:type=&quot;array&quot;&gt;\n                    &lt;item name=&quot;config&quot; xsi:type=&quot;array&quot;&gt;\n                        &lt;item name=&quot;templates&quot; xsi:type=&quot;array&quot;&gt;\n                            &lt;item name=&quot;filters&quot; xsi:type=&quot;array&quot;&gt;\n                                &lt;item name=&quot;select&quot; xsi:type=&quot;array&quot;&gt;\n                                    &lt;item name=&quot;component&quot; xsi:type=&quot;string&quot;&gt;Magento_Ui\/js\/form\/element\/ui-select&lt;\/item&gt;\n                                    &lt;item name=&quot;template&quot; xsi:type=&quot;string&quot;&gt;ui\/grid\/filters\/elements\/ui-select&lt;\/item&gt;\n                                &lt;\/item&gt;\n                            &lt;\/item&gt;\n                        &lt;\/item&gt;\n                    &lt;\/item&gt;\n                &lt;\/argument&gt;\n        &lt;\/filters&gt;\n        &lt;paging name=&quot;listing_paging&quot;\/&gt;\n    &lt;\/listingToolbar&gt;\n    &lt;columns name=&quot;blogmanager_blog_columns&quot;&gt;\n        &lt;column name=&quot;entity_id&quot;&gt;\n            &lt;settings&gt;\n                &lt;filter&gt;textRange&lt;\/filter&gt;\n                &lt;label translate=&quot;true&quot;&gt;ID&lt;\/label&gt;\n                &lt;resizeDefaultWidth&gt;25&lt;\/resizeDefaultWidth&gt;\n            &lt;\/settings&gt;\n        &lt;\/column&gt;\n        &lt;column name=&quot;user_name&quot;&gt;\n            &lt;settings&gt;\n                &lt;filter&gt;text&lt;\/filter&gt;\n                &lt;label translate=&quot;true&quot;&gt;User&lt;\/label&gt;\n            &lt;\/settings&gt;\n        &lt;\/column&gt;\n        &lt;column name=&quot;title&quot;&gt;\n            &lt;settings&gt;\n                &lt;filter&gt;text&lt;\/filter&gt;\n                &lt;label translate=&quot;true&quot;&gt;Title&lt;\/label&gt;\n            &lt;\/settings&gt;\n        &lt;\/column&gt;\n        &lt;column name=&quot;content&quot; class=&quot;Webkul\\BlogManager\\Ui\\Component\\Listing\\Columns\\Content&quot;&gt;\n            &lt;settings&gt;\n                &lt;filter&gt;false&lt;\/filter&gt;\n                &lt;sortable&gt;false&lt;\/sortable&gt;\n                &lt;label translate=&quot;true&quot;&gt;Content&lt;\/label&gt;\n            &lt;\/settings&gt;\n        &lt;\/column&gt;\n        &lt;column name=&quot;status&quot; component=&quot;Magento_Ui\/js\/grid\/columns\/select&quot;&gt;\n            &lt;settings&gt;\n                &lt;options class=&quot;Webkul\\BlogManager\\Model\\Blog\\Status&quot;\/&gt;\n                &lt;dataType&gt;select&lt;\/dataType&gt;\n                &lt;filter&gt;select&lt;\/filter&gt;\n                &lt;sortable&gt;false&lt;\/sortable&gt;\n                &lt;label translate=&quot;true&quot;&gt;Status&lt;\/label&gt;\n            &lt;\/settings&gt;\n        &lt;\/column&gt;\n        &lt;column name=&quot;updated_at&quot; component=&quot;Magento_Ui\/js\/grid\/columns\/date&quot;&gt;\n            &lt;settings&gt;\n                &lt;filter&gt;dateRange&lt;\/filter&gt;\n                &lt;dataType&gt;date&lt;\/dataType&gt;\n                &lt;label translate=&quot;true&quot;&gt;Updated&lt;\/label&gt;\n            &lt;\/settings&gt;\n        &lt;\/column&gt;\n        &lt;column name=&quot;created_at&quot; component=&quot;Magento_Ui\/js\/grid\/columns\/date&quot;&gt;\n            &lt;settings&gt;\n                &lt;filter&gt;dateRange&lt;\/filter&gt;\n                &lt;dataType&gt;date&lt;\/dataType&gt;\n                &lt;label translate=&quot;true&quot;&gt;Created&lt;\/label&gt;\n            &lt;\/settings&gt;\n        &lt;\/column&gt;\n    &lt;\/columns&gt;\n&lt;\/listing&gt;<\/pre>\n\n\n\n<p>Now you should see something like,<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1200\" height=\"337\" src=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/03\/2021-03-05_13-47-1200x337.png\" alt=\"2021-03-05_13-47\" class=\"wp-image-284498\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/03\/2021-03-05_13-47-1200x337.png 1200w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/03\/2021-03-05_13-47-300x84.png 300w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/03\/2021-03-05_13-47-250x70.png 250w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/03\/2021-03-05_13-47-768x216.png 768w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/03\/2021-03-05_13-47-1536x431.png 1536w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/03\/2021-03-05_13-47.png 1812w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" loading=\"lazy\" \/><\/figure>\n\n\n\n<p>Please check out these blogs to learn more about join in SQL,<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-photo is-provider-webkul-blog wp-block-embed-webkul-blog\"><div class=\"wp-block-embed__wrapper\">\nhttps:\/\/webkul.com\/blog\/magento2-mysql-join-explained\/\n<\/div><\/figure>\n\n\n\n<figure class=\"wp-block-embed is-type-photo is-provider-webkul-blog wp-block-embed-webkul-blog\"><div class=\"wp-block-embed__wrapper\">\nhttps:\/\/webkul.com\/blog\/how-to-apply-join-in-collection-in-uicomponent-grid-in-magento2\/\n<\/div><\/figure>\n\n\n\n<p>Folder Structure,<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"399\" height=\"583\" src=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/03\/2021-03-05_14-22.png\" alt=\"2021-03-05_14-22\" class=\"wp-image-284511\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/03\/2021-03-05_14-22.png 399w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/03\/2021-03-05_14-22-205x300.png 205w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/03\/2021-03-05_14-22-170x249.png 170w\" sizes=\"(max-width: 399px) 100vw, 399px\" loading=\"lazy\" \/><\/figure>\n\n\n\n<p>A reliable <a href=\"https:\/\/webkul.com\/magento-development\/\">Magento development company<\/a> can customize the admin grid to improve store management efficiency.<\/p>\n\n\n\n<p><br>Next Blog -> <a href=\"https:\/\/webkul.com\/blog\/magento-development-15-massaction\/\">Magento 2 Development 18: MassAction<\/a><\/p>\n\n\n\n<p>Previous Blog -&gt;&nbsp;<a href=\"https:\/\/webkul.com\/blog\/magento-development-13-uicomponent-and-di-xml\/\" target=\"_blank\" rel=\"noreferrer noopener\">Magento 2 Development 16: uiComponent and di.xml<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In the previous blog, we created a very basic admin grid. Here we will modify it a little bit. Class of a Column In the previous grid, we have not shown the content of the blog. That is because the blog content will be large and it will not be practical to show the whole <a href=\"https:\/\/webkul.com\/blog\/magento-development-14-more-about-admin-grid\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":201,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9121],"tags":[2056,2460],"class_list":["post-284323","post","type-post","status-publish","format-standard","hentry","category-magento-2","tag-magento","tag-magento-2"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Magento 2 Development 17: More about Admin Grid - Webkul Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/webkul.com\/blog\/magento-development-14-more-about-admin-grid\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Magento 2 Development 17: More about Admin Grid - Webkul Blog\" \/>\n<meta property=\"og:description\" content=\"In the previous blog, we created a very basic admin grid. Here we will modify it a little bit. Class of a Column In the previous grid, we have not shown the content of the blog. That is because the blog content will be large and it will not be practical to show the whole [...]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webkul.com\/blog\/magento-development-14-more-about-admin-grid\/\" \/>\n<meta property=\"og:site_name\" content=\"Webkul Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webkul\/\" \/>\n<meta property=\"article:published_time\" content=\"2021-03-05T08:58:24+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-05-30T13:28:22+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2021\/03\/2021-03-05_11-03-1200x414.png\" \/>\n<meta name=\"author\" content=\"Sanjay Chouhan\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webkul\" \/>\n<meta name=\"twitter:site\" content=\"@webkul\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Sanjay Chouhan\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/webkul.com\/blog\/magento-development-14-more-about-admin-grid\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/magento-development-14-more-about-admin-grid\/\"},\"author\":{\"name\":\"Sanjay Chouhan\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/645580979f637b0e355deea21bd07462\"},\"headline\":\"Magento 2 Development 17: More about Admin Grid\",\"datePublished\":\"2021-03-05T08:58:24+00:00\",\"dateModified\":\"2025-05-30T13:28:22+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/magento-development-14-more-about-admin-grid\/\"},\"wordCount\":1065,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/magento-development-14-more-about-admin-grid\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2021\/03\/2021-03-05_11-03-1200x414.png\",\"keywords\":[\"magento\",\"Magento 2\"],\"articleSection\":[\"Magento 2\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/webkul.com\/blog\/magento-development-14-more-about-admin-grid\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/webkul.com\/blog\/magento-development-14-more-about-admin-grid\/\",\"url\":\"https:\/\/webkul.com\/blog\/magento-development-14-more-about-admin-grid\/\",\"name\":\"Magento 2 Development 17: More about Admin Grid - Webkul Blog\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/magento-development-14-more-about-admin-grid\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/magento-development-14-more-about-admin-grid\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2021\/03\/2021-03-05_11-03-1200x414.png\",\"datePublished\":\"2021-03-05T08:58:24+00:00\",\"dateModified\":\"2025-05-30T13:28:22+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/webkul.com\/blog\/magento-development-14-more-about-admin-grid\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webkul.com\/blog\/magento-development-14-more-about-admin-grid\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/magento-development-14-more-about-admin-grid\/#primaryimage\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/03\/2021-03-05_11-03.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/03\/2021-03-05_11-03.png\",\"width\":1835,\"height\":633,\"caption\":\"2021-03-05_11-03\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webkul.com\/blog\/magento-development-14-more-about-admin-grid\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Magento 2 Development 17: More about Admin Grid\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/webkul.com\/blog\/#website\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"name\":\"Webkul Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/webkul.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/webkul.com\/blog\/#organization\",\"name\":\"WebKul Software Private Limited\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"width\":380,\"height\":380,\"caption\":\"WebKul Software Private Limited\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webkul\/\",\"https:\/\/x.com\/webkul\",\"https:\/\/www.instagram.com\/webkul\/\",\"https:\/\/www.linkedin.com\/company\/webkul\",\"https:\/\/www.youtube.com\/user\/webkul\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/645580979f637b0e355deea21bd07462\",\"name\":\"Sanjay Chouhan\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/cd6ee19f99bd1fcafef819135529c952d7c875d06fedd9fd4c4eb0996bafc1bd?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/cd6ee19f99bd1fcafef819135529c952d7c875d06fedd9fd4c4eb0996bafc1bd?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"caption\":\"Sanjay Chouhan\"},\"sameAs\":[\"https:\/\/www.instagram.com\/sanjaychouhansc\/\",\"https:\/\/in.linkedin.com\/in\/scchouhansanjay\"],\"url\":\"https:\/\/webkul.com\/blog\/author\/sanjay-chouhan180\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Magento 2 Development 17: More about Admin Grid - Webkul Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/webkul.com\/blog\/magento-development-14-more-about-admin-grid\/","og_locale":"en_US","og_type":"article","og_title":"Magento 2 Development 17: More about Admin Grid - Webkul Blog","og_description":"In the previous blog, we created a very basic admin grid. Here we will modify it a little bit. Class of a Column In the previous grid, we have not shown the content of the blog. That is because the blog content will be large and it will not be practical to show the whole [...]","og_url":"https:\/\/webkul.com\/blog\/magento-development-14-more-about-admin-grid\/","og_site_name":"Webkul Blog","article_publisher":"https:\/\/www.facebook.com\/webkul\/","article_published_time":"2021-03-05T08:58:24+00:00","article_modified_time":"2025-05-30T13:28:22+00:00","og_image":[{"url":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2021\/03\/2021-03-05_11-03-1200x414.png","type":"","width":"","height":""}],"author":"Sanjay Chouhan","twitter_card":"summary_large_image","twitter_creator":"@webkul","twitter_site":"@webkul","twitter_misc":{"Written by":"Sanjay Chouhan","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/webkul.com\/blog\/magento-development-14-more-about-admin-grid\/#article","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/magento-development-14-more-about-admin-grid\/"},"author":{"name":"Sanjay Chouhan","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/645580979f637b0e355deea21bd07462"},"headline":"Magento 2 Development 17: More about Admin Grid","datePublished":"2021-03-05T08:58:24+00:00","dateModified":"2025-05-30T13:28:22+00:00","mainEntityOfPage":{"@id":"https:\/\/webkul.com\/blog\/magento-development-14-more-about-admin-grid\/"},"wordCount":1065,"commentCount":0,"publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"image":{"@id":"https:\/\/webkul.com\/blog\/magento-development-14-more-about-admin-grid\/#primaryimage"},"thumbnailUrl":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2021\/03\/2021-03-05_11-03-1200x414.png","keywords":["magento","Magento 2"],"articleSection":["Magento 2"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/webkul.com\/blog\/magento-development-14-more-about-admin-grid\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/webkul.com\/blog\/magento-development-14-more-about-admin-grid\/","url":"https:\/\/webkul.com\/blog\/magento-development-14-more-about-admin-grid\/","name":"Magento 2 Development 17: More about Admin Grid - Webkul Blog","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/webkul.com\/blog\/magento-development-14-more-about-admin-grid\/#primaryimage"},"image":{"@id":"https:\/\/webkul.com\/blog\/magento-development-14-more-about-admin-grid\/#primaryimage"},"thumbnailUrl":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2021\/03\/2021-03-05_11-03-1200x414.png","datePublished":"2021-03-05T08:58:24+00:00","dateModified":"2025-05-30T13:28:22+00:00","breadcrumb":{"@id":"https:\/\/webkul.com\/blog\/magento-development-14-more-about-admin-grid\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webkul.com\/blog\/magento-development-14-more-about-admin-grid\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/magento-development-14-more-about-admin-grid\/#primaryimage","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/03\/2021-03-05_11-03.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/03\/2021-03-05_11-03.png","width":1835,"height":633,"caption":"2021-03-05_11-03"},{"@type":"BreadcrumbList","@id":"https:\/\/webkul.com\/blog\/magento-development-14-more-about-admin-grid\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Magento 2 Development 17: More about Admin Grid"}]},{"@type":"WebSite","@id":"https:\/\/webkul.com\/blog\/#website","url":"https:\/\/webkul.com\/blog\/","name":"Webkul Blog","description":"","publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/webkul.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/webkul.com\/blog\/#organization","name":"WebKul Software Private Limited","url":"https:\/\/webkul.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","width":380,"height":380,"caption":"WebKul Software Private Limited"},"image":{"@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webkul\/","https:\/\/x.com\/webkul","https:\/\/www.instagram.com\/webkul\/","https:\/\/www.linkedin.com\/company\/webkul","https:\/\/www.youtube.com\/user\/webkul\/"]},{"@type":"Person","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/645580979f637b0e355deea21bd07462","name":"Sanjay Chouhan","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/cd6ee19f99bd1fcafef819135529c952d7c875d06fedd9fd4c4eb0996bafc1bd?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/cd6ee19f99bd1fcafef819135529c952d7c875d06fedd9fd4c4eb0996bafc1bd?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","caption":"Sanjay Chouhan"},"sameAs":["https:\/\/www.instagram.com\/sanjaychouhansc\/","https:\/\/in.linkedin.com\/in\/scchouhansanjay"],"url":"https:\/\/webkul.com\/blog\/author\/sanjay-chouhan180\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/284323","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/users\/201"}],"replies":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/comments?post=284323"}],"version-history":[{"count":20,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/284323\/revisions"}],"predecessor-version":[{"id":494278,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/284323\/revisions\/494278"}],"wp:attachment":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media?parent=284323"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/categories?post=284323"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/tags?post=284323"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}