Customer grid uiComponent in slide out modal (Admin)

I want to open a modal in the backend when i click on a button in the admin bar above in the page. In this modal a customer grid uiComponent needs to be shown.

The uiComponent is getting loaded through ajax but the data is never rendered.
When i click the button in “Duplicate for other customer” a new slide-out modal will be opened. In the network tab the data for the grid that needs to be parsed will be fetched through AJAX. But the response will never be added to the customer grid and the customer grid will never be shown in the modal. The only thing i see is the spinner during the ajax request for the grid data.

quote.js: This file handle’s the modal.

define([
    'jquery',
    'Magento_Ui/js/modal/modal',
    'mage/url'
], ($, modal, urlBuilder) => {

    return (config, element) => {
        window.keepMultiModalWindow = true;
        window.requestAQuoteExtender = {
            modal: null,
            duplicate: () => {
                this.doRequest(
                    config.duplicateUrl,
                    'POST',
                    {
                        quote_id: config.quote_id
                    }
                ).done((response) => {
                    window.location.assign(response.redirect);
                });
            },
            duplicateOtherCustomer() {
                this.doRequest(config.duplicateOtherCustomerUrl)
                    .done((data, textStatus, transport) => {
                        const dataHtml = $(data);
                        this.openModal(dataHtml[1]);
                    })
            },
            openModal(data) {
console.log('openModal');
console.log(data);
                if (this.modal) {
console.log('modal exists');
                    this.modal.html(
                        $(data).html()
                    ).trigger('contentUpdated');

                    return;
                }

console.log('Create modal')
                var modalOptions = {
                    title: 'Choose customer',
                    modalClass: 'magento',
                    type: 'slide',
                    buttons: [{
                        text: $.mage.__('Close'),
                        class: 'action- scalable back',
                        click: () => {
                            this.closeModal(this);
                        }
                    }],
                    close: () => {
                        this.closeModal(this);
                    }
                }

                this.modal = $(data).modal(modalOptions);
                this.modal.modal('openModal').trigger('contentUpdated');
            },
            closeModal(modal) {
                $('body').trigger('processStop');
                modal.closeModal();
            },
            doRequest: (url, method = 'GET', data = null) => {
                const ajaxObj = {
                    url: url,
                    method: method,
                    data: data,
                    dataType: 'html',
                    showLoader: true
                }

                if (data !== null) {
                    ajaxObj.data = data;
                }

                return $.ajax(ajaxObj);
            }
        };
    };
});

quote.phtml: This file will be added on the admin page where i can click on a button to open the modal.

<?php declare(strict_types=1);

/**
 * Merxtrade - Request A Quote Extender
 *
 * This module adds extra functionality to the Amasty Request A Quote module.
 *
 * Copyright © E-Tales B.V. 2024-present. All rights reserved.
 */

use MagentoBackendBlockTemplate;

/** @var Template $block */
?>
<script type="text/x-magento-init">
{
    "#duplicate": {
        "etalesRequestAQuoteExtender": {
            "duplicateUrl": "<?= $block->getUrl('etales_quoteextender/quote/duplicate') ?>",
            "duplicateOtherCustomerUrl": "<?= $block->getUrl('etales_quoteextender/quote/customergridui') ?>",
            "quote_id": "<?= $this->getRequest()->getParam('quote_id') ?>"
        }
    }
}
</script>

Controller/Adminhtml/Quote/CustomerGridUi.php: This file handle’s the ajax request for the customer grid uiComponent.

<?php

declare(strict_types=1);

namespace EtalesRequestAQuoteExtenderControllerAdminhtmlQuote;

use MagentoFrameworkAppActionHttpGetActionInterface;
use MagentoFrameworkViewResultLayout;
use MagentoFrameworkViewResultLayoutFactory;

class CustomerGridUi implements HttpGetActionInterface
{
    public function __construct(
        private readonly LayoutFactory $layoutFactory,
    ) {
    }

    public function execute()
    {
        /** @var Layout $layoutFactory */
        return $this->layoutFactory->create();
    }
}

view/adminhtml/layout/etales_quoteextender_quote_customergridui.xml: This file inserts the uiComponent for the above controller.

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <container name="content">
            <uiComponent name="etales_requestaquoteextender_customer_grid" />
        </container>
    </body>
</page>

etales_requestaquoteextender_customer_grid.xml: This is the uiComponent that is used.

<?xml version="1.0"?>
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
    <argument name="data" xsi:type="array">
        <item name="js_config" xsi:type="array">
            <item name="provider" xsi:type="string">
                etales_requestaquoteextender_customer_grid.etales_requestaquoteextender_customer_grid_data_source
            </item>
        </item>
    </argument>
    <settings>
        <spinner>etales_requestaquoteextender_customer_grid_columns</spinner>
        <deps>
            <dep>etales_requestaquoteextender_customer_grid.etales_requestaquoteextender_customer_grid_data_source</dep>
        </deps>
    </settings>
    <dataSource name="etales_requestaquoteextender_customer_grid_data_source" component="Magento_Ui/js/grid/provider">
        <settings>
            <updateUrl path="mui/index/render"/>
        </settings>
        <dataProvider name="etales_requestaquoteextender_customer_grid_data_source"
            class="MagentoFrameworkViewElementUiComponentDataProviderDataProvider">
            <settings>
                <primaryFieldName>entity_id</primaryFieldName>
                <requestFieldName>id</requestFieldName>
            </settings>
        </dataProvider>
    </dataSource>
    <listingToolbar name="listing_top">
        <bookmark name="bookmarks"/>
        <columnsControls name="columns_controls"/>
        <filters name="listing_filters"/>
        <paging name="listing_paging"/>
    </listingToolbar>
    <columns name="etales_requestaquoteextender_customer_grid_columns" class="MagentoUiComponentListingColumns">
        <column name="entity_id" sortOrder="10">
            <settings>
                <filter>text</filter>
                <label translate="true">ID</label>
            </settings>
        </column>
        <column name="company" sortOrder="20">
            <settings>
                <filter>text</filter>
                <label translate="true">Company</label>
            </settings>
        </column>
        <column name="firstname" sortOrder="30">
            <settings>
                <filter>text</filter>
                <label translate="true">Firstname</label>
            </settings>
        </column>
        <column name="lastname" sortOrder="40">
            <settings>
                <filter>text</filter>
                <label translate="true">Lastname</label>
            </settings>
        </column>
        <column name="email" sortOrder="50">
            <settings>
                <filter>text</filter>
                <label translate="true">E-mail address</label>
            </settings>
        </column>
    </columns>
</listing>

di.xml In this file i have created the collection for the customer grid.

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="MagentoFrameworkViewElementUiComponentDataProviderCollectionFactory">
    <arguments>
        <argument name="collections" xsi:type="array">
            <item name="etales_requestaquoteextender_customer_grid_data_source" xsi:type="string">
                EtalesRequestAQuoteExtenderModelResourceModelCustomerGridCollection
            </item>
        </argument>
    </arguments>
</type>
    <virtualType name="EtalesRequestAQuoteExtenderModelResourceModelCustomerGridCollection"
                 type="MagentoFrameworkViewElementUiComponentDataProviderSearchResult">
        <arguments>
            <argument name="mainTable" xsi:type="string">customer_entity</argument>
            <argument name="resourceModel" xsi:type="string">MagentoCustomerModelResourceModelCustomer</argument>
        </arguments>
    </virtualType>
</config>

If i add the uiComponent through the layout xml of the page where i want to open the modal it will be correctly rendered on the page. But with my code above it just doesn’t render the grid in the modal but all other things like getting the data for the grid etc is working.

Anybody who can point me in the right direction or sees what i am doing wrong?

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa

Customer grid uiComponent in slide out modal (Admin)

I want to open a modal in the backend when i click on a button in the admin bar above in the page. In this modal a customer grid uiComponent needs to be shown.

The uiComponent is getting loaded through ajax but the data is never rendered.
When i click the button in “Duplicate for other customer” a new slide-out modal will be opened. In the network tab the data for the grid that needs to be parsed will be fetched through AJAX. But the response will never be added to the customer grid and the customer grid will never be shown in the modal. The only thing i see is the spinner during the ajax request for the grid data.

quote.js: This file handle’s the modal.

define([
    'jquery',
    'Magento_Ui/js/modal/modal',
    'mage/url'
], ($, modal, urlBuilder) => {

    return (config, element) => {
        window.keepMultiModalWindow = true;
        window.requestAQuoteExtender = {
            modal: null,
            duplicate: () => {
                this.doRequest(
                    config.duplicateUrl,
                    'POST',
                    {
                        quote_id: config.quote_id
                    }
                ).done((response) => {
                    window.location.assign(response.redirect);
                });
            },
            duplicateOtherCustomer() {
                this.doRequest(config.duplicateOtherCustomerUrl)
                    .done((data, textStatus, transport) => {
                        const dataHtml = $(data);
                        this.openModal(dataHtml[1]);
                    })
            },
            openModal(data) {
console.log('openModal');
console.log(data);
                if (this.modal) {
console.log('modal exists');
                    this.modal.html(
                        $(data).html()
                    ).trigger('contentUpdated');

                    return;
                }

console.log('Create modal')
                var modalOptions = {
                    title: 'Choose customer',
                    modalClass: 'magento',
                    type: 'slide',
                    buttons: [{
                        text: $.mage.__('Close'),
                        class: 'action- scalable back',
                        click: () => {
                            this.closeModal(this);
                        }
                    }],
                    close: () => {
                        this.closeModal(this);
                    }
                }

                this.modal = $(data).modal(modalOptions);
                this.modal.modal('openModal').trigger('contentUpdated');
            },
            closeModal(modal) {
                $('body').trigger('processStop');
                modal.closeModal();
            },
            doRequest: (url, method = 'GET', data = null) => {
                const ajaxObj = {
                    url: url,
                    method: method,
                    data: data,
                    dataType: 'html',
                    showLoader: true
                }

                if (data !== null) {
                    ajaxObj.data = data;
                }

                return $.ajax(ajaxObj);
            }
        };
    };
});

quote.phtml: This file will be added on the admin page where i can click on a button to open the modal.

<?php declare(strict_types=1);

/**
 * Merxtrade - Request A Quote Extender
 *
 * This module adds extra functionality to the Amasty Request A Quote module.
 *
 * Copyright © E-Tales B.V. 2024-present. All rights reserved.
 */

use MagentoBackendBlockTemplate;

/** @var Template $block */
?>
<script type="text/x-magento-init">
{
    "#duplicate": {
        "etalesRequestAQuoteExtender": {
            "duplicateUrl": "<?= $block->getUrl('etales_quoteextender/quote/duplicate') ?>",
            "duplicateOtherCustomerUrl": "<?= $block->getUrl('etales_quoteextender/quote/customergridui') ?>",
            "quote_id": "<?= $this->getRequest()->getParam('quote_id') ?>"
        }
    }
}
</script>

Controller/Adminhtml/Quote/CustomerGridUi.php: This file handle’s the ajax request for the customer grid uiComponent.

<?php

declare(strict_types=1);

namespace EtalesRequestAQuoteExtenderControllerAdminhtmlQuote;

use MagentoFrameworkAppActionHttpGetActionInterface;
use MagentoFrameworkViewResultLayout;
use MagentoFrameworkViewResultLayoutFactory;

class CustomerGridUi implements HttpGetActionInterface
{
    public function __construct(
        private readonly LayoutFactory $layoutFactory,
    ) {
    }

    public function execute()
    {
        /** @var Layout $layoutFactory */
        return $this->layoutFactory->create();
    }
}

view/adminhtml/layout/etales_quoteextender_quote_customergridui.xml: This file inserts the uiComponent for the above controller.

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <container name="content">
            <uiComponent name="etales_requestaquoteextender_customer_grid" />
        </container>
    </body>
</page>

etales_requestaquoteextender_customer_grid.xml: This is the uiComponent that is used.

<?xml version="1.0"?>
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
    <argument name="data" xsi:type="array">
        <item name="js_config" xsi:type="array">
            <item name="provider" xsi:type="string">
                etales_requestaquoteextender_customer_grid.etales_requestaquoteextender_customer_grid_data_source
            </item>
        </item>
    </argument>
    <settings>
        <spinner>etales_requestaquoteextender_customer_grid_columns</spinner>
        <deps>
            <dep>etales_requestaquoteextender_customer_grid.etales_requestaquoteextender_customer_grid_data_source</dep>
        </deps>
    </settings>
    <dataSource name="etales_requestaquoteextender_customer_grid_data_source" component="Magento_Ui/js/grid/provider">
        <settings>
            <updateUrl path="mui/index/render"/>
        </settings>
        <dataProvider name="etales_requestaquoteextender_customer_grid_data_source"
            class="MagentoFrameworkViewElementUiComponentDataProviderDataProvider">
            <settings>
                <primaryFieldName>entity_id</primaryFieldName>
                <requestFieldName>id</requestFieldName>
            </settings>
        </dataProvider>
    </dataSource>
    <listingToolbar name="listing_top">
        <bookmark name="bookmarks"/>
        <columnsControls name="columns_controls"/>
        <filters name="listing_filters"/>
        <paging name="listing_paging"/>
    </listingToolbar>
    <columns name="etales_requestaquoteextender_customer_grid_columns" class="MagentoUiComponentListingColumns">
        <column name="entity_id" sortOrder="10">
            <settings>
                <filter>text</filter>
                <label translate="true">ID</label>
            </settings>
        </column>
        <column name="company" sortOrder="20">
            <settings>
                <filter>text</filter>
                <label translate="true">Company</label>
            </settings>
        </column>
        <column name="firstname" sortOrder="30">
            <settings>
                <filter>text</filter>
                <label translate="true">Firstname</label>
            </settings>
        </column>
        <column name="lastname" sortOrder="40">
            <settings>
                <filter>text</filter>
                <label translate="true">Lastname</label>
            </settings>
        </column>
        <column name="email" sortOrder="50">
            <settings>
                <filter>text</filter>
                <label translate="true">E-mail address</label>
            </settings>
        </column>
    </columns>
</listing>

di.xml In this file i have created the collection for the customer grid.

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="MagentoFrameworkViewElementUiComponentDataProviderCollectionFactory">
    <arguments>
        <argument name="collections" xsi:type="array">
            <item name="etales_requestaquoteextender_customer_grid_data_source" xsi:type="string">
                EtalesRequestAQuoteExtenderModelResourceModelCustomerGridCollection
            </item>
        </argument>
    </arguments>
</type>
    <virtualType name="EtalesRequestAQuoteExtenderModelResourceModelCustomerGridCollection"
                 type="MagentoFrameworkViewElementUiComponentDataProviderSearchResult">
        <arguments>
            <argument name="mainTable" xsi:type="string">customer_entity</argument>
            <argument name="resourceModel" xsi:type="string">MagentoCustomerModelResourceModelCustomer</argument>
        </arguments>
    </virtualType>
</config>

If i add the uiComponent through the layout xml of the page where i want to open the modal it will be correctly rendered on the page. But with my code above it just doesn’t render the grid in the modal but all other things like getting the data for the grid etc is working.

Anybody who can point me in the right direction or sees what i am doing wrong?

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa

Customer grid uiComponent in slide out modal (Admin)

I want to open a modal in the backend when i click on a button in the admin bar above in the page. In this modal a customer grid uiComponent needs to be shown.

The uiComponent is getting loaded through ajax but the data is never rendered.
When i click the button in “Duplicate for other customer” a new slide-out modal will be opened. In the network tab the data for the grid that needs to be parsed will be fetched through AJAX. But the response will never be added to the customer grid and the customer grid will never be shown in the modal. The only thing i see is the spinner during the ajax request for the grid data.

quote.js: This file handle’s the modal.

define([
    'jquery',
    'Magento_Ui/js/modal/modal',
    'mage/url'
], ($, modal, urlBuilder) => {

    return (config, element) => {
        window.keepMultiModalWindow = true;
        window.requestAQuoteExtender = {
            modal: null,
            duplicate: () => {
                this.doRequest(
                    config.duplicateUrl,
                    'POST',
                    {
                        quote_id: config.quote_id
                    }
                ).done((response) => {
                    window.location.assign(response.redirect);
                });
            },
            duplicateOtherCustomer() {
                this.doRequest(config.duplicateOtherCustomerUrl)
                    .done((data, textStatus, transport) => {
                        const dataHtml = $(data);
                        this.openModal(dataHtml[1]);
                    })
            },
            openModal(data) {
console.log('openModal');
console.log(data);
                if (this.modal) {
console.log('modal exists');
                    this.modal.html(
                        $(data).html()
                    ).trigger('contentUpdated');

                    return;
                }

console.log('Create modal')
                var modalOptions = {
                    title: 'Choose customer',
                    modalClass: 'magento',
                    type: 'slide',
                    buttons: [{
                        text: $.mage.__('Close'),
                        class: 'action- scalable back',
                        click: () => {
                            this.closeModal(this);
                        }
                    }],
                    close: () => {
                        this.closeModal(this);
                    }
                }

                this.modal = $(data).modal(modalOptions);
                this.modal.modal('openModal').trigger('contentUpdated');
            },
            closeModal(modal) {
                $('body').trigger('processStop');
                modal.closeModal();
            },
            doRequest: (url, method = 'GET', data = null) => {
                const ajaxObj = {
                    url: url,
                    method: method,
                    data: data,
                    dataType: 'html',
                    showLoader: true
                }

                if (data !== null) {
                    ajaxObj.data = data;
                }

                return $.ajax(ajaxObj);
            }
        };
    };
});

quote.phtml: This file will be added on the admin page where i can click on a button to open the modal.

<?php declare(strict_types=1);

/**
 * Merxtrade - Request A Quote Extender
 *
 * This module adds extra functionality to the Amasty Request A Quote module.
 *
 * Copyright © E-Tales B.V. 2024-present. All rights reserved.
 */

use MagentoBackendBlockTemplate;

/** @var Template $block */
?>
<script type="text/x-magento-init">
{
    "#duplicate": {
        "etalesRequestAQuoteExtender": {
            "duplicateUrl": "<?= $block->getUrl('etales_quoteextender/quote/duplicate') ?>",
            "duplicateOtherCustomerUrl": "<?= $block->getUrl('etales_quoteextender/quote/customergridui') ?>",
            "quote_id": "<?= $this->getRequest()->getParam('quote_id') ?>"
        }
    }
}
</script>

Controller/Adminhtml/Quote/CustomerGridUi.php: This file handle’s the ajax request for the customer grid uiComponent.

<?php

declare(strict_types=1);

namespace EtalesRequestAQuoteExtenderControllerAdminhtmlQuote;

use MagentoFrameworkAppActionHttpGetActionInterface;
use MagentoFrameworkViewResultLayout;
use MagentoFrameworkViewResultLayoutFactory;

class CustomerGridUi implements HttpGetActionInterface
{
    public function __construct(
        private readonly LayoutFactory $layoutFactory,
    ) {
    }

    public function execute()
    {
        /** @var Layout $layoutFactory */
        return $this->layoutFactory->create();
    }
}

view/adminhtml/layout/etales_quoteextender_quote_customergridui.xml: This file inserts the uiComponent for the above controller.

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <container name="content">
            <uiComponent name="etales_requestaquoteextender_customer_grid" />
        </container>
    </body>
</page>

etales_requestaquoteextender_customer_grid.xml: This is the uiComponent that is used.

<?xml version="1.0"?>
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
    <argument name="data" xsi:type="array">
        <item name="js_config" xsi:type="array">
            <item name="provider" xsi:type="string">
                etales_requestaquoteextender_customer_grid.etales_requestaquoteextender_customer_grid_data_source
            </item>
        </item>
    </argument>
    <settings>
        <spinner>etales_requestaquoteextender_customer_grid_columns</spinner>
        <deps>
            <dep>etales_requestaquoteextender_customer_grid.etales_requestaquoteextender_customer_grid_data_source</dep>
        </deps>
    </settings>
    <dataSource name="etales_requestaquoteextender_customer_grid_data_source" component="Magento_Ui/js/grid/provider">
        <settings>
            <updateUrl path="mui/index/render"/>
        </settings>
        <dataProvider name="etales_requestaquoteextender_customer_grid_data_source"
            class="MagentoFrameworkViewElementUiComponentDataProviderDataProvider">
            <settings>
                <primaryFieldName>entity_id</primaryFieldName>
                <requestFieldName>id</requestFieldName>
            </settings>
        </dataProvider>
    </dataSource>
    <listingToolbar name="listing_top">
        <bookmark name="bookmarks"/>
        <columnsControls name="columns_controls"/>
        <filters name="listing_filters"/>
        <paging name="listing_paging"/>
    </listingToolbar>
    <columns name="etales_requestaquoteextender_customer_grid_columns" class="MagentoUiComponentListingColumns">
        <column name="entity_id" sortOrder="10">
            <settings>
                <filter>text</filter>
                <label translate="true">ID</label>
            </settings>
        </column>
        <column name="company" sortOrder="20">
            <settings>
                <filter>text</filter>
                <label translate="true">Company</label>
            </settings>
        </column>
        <column name="firstname" sortOrder="30">
            <settings>
                <filter>text</filter>
                <label translate="true">Firstname</label>
            </settings>
        </column>
        <column name="lastname" sortOrder="40">
            <settings>
                <filter>text</filter>
                <label translate="true">Lastname</label>
            </settings>
        </column>
        <column name="email" sortOrder="50">
            <settings>
                <filter>text</filter>
                <label translate="true">E-mail address</label>
            </settings>
        </column>
    </columns>
</listing>

di.xml In this file i have created the collection for the customer grid.

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="MagentoFrameworkViewElementUiComponentDataProviderCollectionFactory">
    <arguments>
        <argument name="collections" xsi:type="array">
            <item name="etales_requestaquoteextender_customer_grid_data_source" xsi:type="string">
                EtalesRequestAQuoteExtenderModelResourceModelCustomerGridCollection
            </item>
        </argument>
    </arguments>
</type>
    <virtualType name="EtalesRequestAQuoteExtenderModelResourceModelCustomerGridCollection"
                 type="MagentoFrameworkViewElementUiComponentDataProviderSearchResult">
        <arguments>
            <argument name="mainTable" xsi:type="string">customer_entity</argument>
            <argument name="resourceModel" xsi:type="string">MagentoCustomerModelResourceModelCustomer</argument>
        </arguments>
    </virtualType>
</config>

If i add the uiComponent through the layout xml of the page where i want to open the modal it will be correctly rendered on the page. But with my code above it just doesn’t render the grid in the modal but all other things like getting the data for the grid etc is working.

Anybody who can point me in the right direction or sees what i am doing wrong?

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa

Customer grid uiComponent in slide out modal (Admin)

I want to open a modal in the backend when i click on a button in the admin bar above in the page. In this modal a customer grid uiComponent needs to be shown.

The uiComponent is getting loaded through ajax but the data is never rendered.
When i click the button in “Duplicate for other customer” a new slide-out modal will be opened. In the network tab the data for the grid that needs to be parsed will be fetched through AJAX. But the response will never be added to the customer grid and the customer grid will never be shown in the modal. The only thing i see is the spinner during the ajax request for the grid data.

quote.js: This file handle’s the modal.

define([
    'jquery',
    'Magento_Ui/js/modal/modal',
    'mage/url'
], ($, modal, urlBuilder) => {

    return (config, element) => {
        window.keepMultiModalWindow = true;
        window.requestAQuoteExtender = {
            modal: null,
            duplicate: () => {
                this.doRequest(
                    config.duplicateUrl,
                    'POST',
                    {
                        quote_id: config.quote_id
                    }
                ).done((response) => {
                    window.location.assign(response.redirect);
                });
            },
            duplicateOtherCustomer() {
                this.doRequest(config.duplicateOtherCustomerUrl)
                    .done((data, textStatus, transport) => {
                        const dataHtml = $(data);
                        this.openModal(dataHtml[1]);
                    })
            },
            openModal(data) {
console.log('openModal');
console.log(data);
                if (this.modal) {
console.log('modal exists');
                    this.modal.html(
                        $(data).html()
                    ).trigger('contentUpdated');

                    return;
                }

console.log('Create modal')
                var modalOptions = {
                    title: 'Choose customer',
                    modalClass: 'magento',
                    type: 'slide',
                    buttons: [{
                        text: $.mage.__('Close'),
                        class: 'action- scalable back',
                        click: () => {
                            this.closeModal(this);
                        }
                    }],
                    close: () => {
                        this.closeModal(this);
                    }
                }

                this.modal = $(data).modal(modalOptions);
                this.modal.modal('openModal').trigger('contentUpdated');
            },
            closeModal(modal) {
                $('body').trigger('processStop');
                modal.closeModal();
            },
            doRequest: (url, method = 'GET', data = null) => {
                const ajaxObj = {
                    url: url,
                    method: method,
                    data: data,
                    dataType: 'html',
                    showLoader: true
                }

                if (data !== null) {
                    ajaxObj.data = data;
                }

                return $.ajax(ajaxObj);
            }
        };
    };
});

quote.phtml: This file will be added on the admin page where i can click on a button to open the modal.

<?php declare(strict_types=1);

/**
 * Merxtrade - Request A Quote Extender
 *
 * This module adds extra functionality to the Amasty Request A Quote module.
 *
 * Copyright © E-Tales B.V. 2024-present. All rights reserved.
 */

use MagentoBackendBlockTemplate;

/** @var Template $block */
?>
<script type="text/x-magento-init">
{
    "#duplicate": {
        "etalesRequestAQuoteExtender": {
            "duplicateUrl": "<?= $block->getUrl('etales_quoteextender/quote/duplicate') ?>",
            "duplicateOtherCustomerUrl": "<?= $block->getUrl('etales_quoteextender/quote/customergridui') ?>",
            "quote_id": "<?= $this->getRequest()->getParam('quote_id') ?>"
        }
    }
}
</script>

Controller/Adminhtml/Quote/CustomerGridUi.php: This file handle’s the ajax request for the customer grid uiComponent.

<?php

declare(strict_types=1);

namespace EtalesRequestAQuoteExtenderControllerAdminhtmlQuote;

use MagentoFrameworkAppActionHttpGetActionInterface;
use MagentoFrameworkViewResultLayout;
use MagentoFrameworkViewResultLayoutFactory;

class CustomerGridUi implements HttpGetActionInterface
{
    public function __construct(
        private readonly LayoutFactory $layoutFactory,
    ) {
    }

    public function execute()
    {
        /** @var Layout $layoutFactory */
        return $this->layoutFactory->create();
    }
}

view/adminhtml/layout/etales_quoteextender_quote_customergridui.xml: This file inserts the uiComponent for the above controller.

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <container name="content">
            <uiComponent name="etales_requestaquoteextender_customer_grid" />
        </container>
    </body>
</page>

etales_requestaquoteextender_customer_grid.xml: This is the uiComponent that is used.

<?xml version="1.0"?>
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
    <argument name="data" xsi:type="array">
        <item name="js_config" xsi:type="array">
            <item name="provider" xsi:type="string">
                etales_requestaquoteextender_customer_grid.etales_requestaquoteextender_customer_grid_data_source
            </item>
        </item>
    </argument>
    <settings>
        <spinner>etales_requestaquoteextender_customer_grid_columns</spinner>
        <deps>
            <dep>etales_requestaquoteextender_customer_grid.etales_requestaquoteextender_customer_grid_data_source</dep>
        </deps>
    </settings>
    <dataSource name="etales_requestaquoteextender_customer_grid_data_source" component="Magento_Ui/js/grid/provider">
        <settings>
            <updateUrl path="mui/index/render"/>
        </settings>
        <dataProvider name="etales_requestaquoteextender_customer_grid_data_source"
            class="MagentoFrameworkViewElementUiComponentDataProviderDataProvider">
            <settings>
                <primaryFieldName>entity_id</primaryFieldName>
                <requestFieldName>id</requestFieldName>
            </settings>
        </dataProvider>
    </dataSource>
    <listingToolbar name="listing_top">
        <bookmark name="bookmarks"/>
        <columnsControls name="columns_controls"/>
        <filters name="listing_filters"/>
        <paging name="listing_paging"/>
    </listingToolbar>
    <columns name="etales_requestaquoteextender_customer_grid_columns" class="MagentoUiComponentListingColumns">
        <column name="entity_id" sortOrder="10">
            <settings>
                <filter>text</filter>
                <label translate="true">ID</label>
            </settings>
        </column>
        <column name="company" sortOrder="20">
            <settings>
                <filter>text</filter>
                <label translate="true">Company</label>
            </settings>
        </column>
        <column name="firstname" sortOrder="30">
            <settings>
                <filter>text</filter>
                <label translate="true">Firstname</label>
            </settings>
        </column>
        <column name="lastname" sortOrder="40">
            <settings>
                <filter>text</filter>
                <label translate="true">Lastname</label>
            </settings>
        </column>
        <column name="email" sortOrder="50">
            <settings>
                <filter>text</filter>
                <label translate="true">E-mail address</label>
            </settings>
        </column>
    </columns>
</listing>

di.xml In this file i have created the collection for the customer grid.

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="MagentoFrameworkViewElementUiComponentDataProviderCollectionFactory">
    <arguments>
        <argument name="collections" xsi:type="array">
            <item name="etales_requestaquoteextender_customer_grid_data_source" xsi:type="string">
                EtalesRequestAQuoteExtenderModelResourceModelCustomerGridCollection
            </item>
        </argument>
    </arguments>
</type>
    <virtualType name="EtalesRequestAQuoteExtenderModelResourceModelCustomerGridCollection"
                 type="MagentoFrameworkViewElementUiComponentDataProviderSearchResult">
        <arguments>
            <argument name="mainTable" xsi:type="string">customer_entity</argument>
            <argument name="resourceModel" xsi:type="string">MagentoCustomerModelResourceModelCustomer</argument>
        </arguments>
    </virtualType>
</config>

If i add the uiComponent through the layout xml of the page where i want to open the modal it will be correctly rendered on the page. But with my code above it just doesn’t render the grid in the modal but all other things like getting the data for the grid etc is working.

Anybody who can point me in the right direction or sees what i am doing wrong?

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật