Hello Magento Friends,

In Magento 2, customizations to the admin panel can significantly enhance the user experience and simplify management tasks. One such customization is adding a “View” button to the admin grid, allowing users to quickly open a detailed view of an item in a slide window. This approach eliminates the need to navigate away from the grid, providing admins a faster, more seamless experience.

In this blog, we’ll walk through the process of adding a View button in an admin grid and configuring it to open a detailed view in a slide window.

Steps to Add View Button in Admin Grid to Open a View Page in Slide Window in Magento 2:

Step 1: Create your_uicomponent_listing.xml file in the path given below

{{magento_root}}\app\code\Vendor\Extension\view\adminhtml\ui_component\your_uicomponent_listing.xml

Now, add the code as follows

Step 2: Create a ViewAction.php in the given below path

{{magento_root}}\app\code\Vendor\Extension\Ui\Component\Listing\Column\ViewAction.php

Then add the below-mentioned code

Step 3: Create a vendor_extension_index.xml file in the given below path

{{magento_root}}\app\code\Vendor\Extension\view\adminhtml\layout\vendor_extension_index.xml

Now, include the following piece of code

<?xml version=”1.0″ encoding=”UTF-8″?>

Step 4: Create a js.phtml file in the path given below

{{magento_root}}\app\code\Vendor\Extension\view\adminhtml\templates\view\js.phtml

Now add the following code snippet

Step 5: Create a Selector.php file in the given below path

{{magento_root}}\app\code\Vendor\Extension\Block\Adminhtml\Selector.php

After that, add the below code

Step 6: Create a View.php file in the given below path

{{magento_root}}\app\code\Vendor\Extension\Controller\Adminhtml\Grid\View.php

And add the code as follows

Step 7: Create a View.php file in the given below path

{{magento_root}}\app\code\Vendor\Extension\Block\Adminhtml\View.php

Now add the following code

Step 8: Create a view.phtml file in the given below path

{{magento_root}}\app\code\Vendor\Extension\view\adminhtml\templates\view.phtml

Then add the following code

Output:

View button

slide window

Conclusion:

Adding a View button to the Magento 2 admin grid and configuring it to open a slide window can significantly improve admin workflows. By following this guide, you can enable quick viewing of entity details without leaving the grid page, enhancing the overall user experience.

Relevant Read – 

Magento 2: How to Add a Custom Button to Open Custom Popup in Admin Grid

Feel free to modify the JavaScript and layout files to match your project’s specific needs. With Magento 2’s flexible UI components, you can further extend this functionality to suit other use cases.

Happy Coding!

Click to rate this post!
[Total: 1 Average: 5]