cancel
Showing results for 
Search instead for 
Did you mean: 

override base template file in adminhtml [Magento-Ui backend]

SOLVED

override base template file in adminhtml [Magento-Ui backend]

Hi,

I created custom grid module using ui component layout

In that i want to add new button near to filter button.

That new button should functions like action drop down function i.e capture all selected items in grid.

 

I tried to override following file in my admin module as above but its fails. 

Magento\vendor\magento\module-ui\view\base\web\templates\grid\filters\filters.html

 

 

I used requirejs config file in following path

<Namespace>\<Module>\view\adminhtml\requirejs-config.js

my override filter file in

<Namespace>\<Module>\view\adminhtml\templates\grid\filters\filters.html

 

requirejs-config.js:

 

var config = {
  "map": {
    "*": {
      "Magento_Ui/templates/grid/filters/filters.html": 
          "<Namespace>_<Module>/template/grid/filters/filters.html"
    }
  }
};

 

I am using Magento 2.1 CE version.

 

Suggesstion pls.

 

Thanks.

2 ACCEPTED SOLUTIONS

Accepted Solutions

Re: override base template file in adminhtml [Magento-Ui backend]

You can try with below way,

 

create requirejs-config.js file inside base folder instead of adminhtml folder,

var config = {
  "map": {
    "*": {
      "Magento_Ui/templates/grid/filters/filters": 
          "<Namespace>_<Module>/template/grid/filters/filters"
    }
  }
};

Remove html from templates defination

Also create template folder in your module inside base directory not use adminhtml directory,

 

New Folder Path:

<Namespace>\<Module>\view\base\web\template\grid\filters\filters.html

 

Run command,

php bin/magento setup:upgrade
php bin/magento setup:static-content:deploy

 

I have updated my answer.

 

if issue resolved, Click Kudos/Accept as solutions.

 

 

If Issue Solved, Click Kudos/Accept As solutions. Get Magento insight from
Magento 2 Blogs/Tutorial

View solution in original post

Re: override base template file in adminhtml [Magento-Ui backend]

Thanks Its working as you suggest.

We need one small change in our requirejs-config.js in our base folder

 

Magento_Ui/templates is mapped to ui/template in Magento\vendor\magento\module-ui\view\base\requirejs-config.js

 

So we need to remap from Magento_Ui/templates/grid/filters/filters to ui/template/grid/filters/filters

View solution in original post

7 REPLIES 7

Re: override base template file in adminhtml [Magento-Ui backend]

You can try with below way,

 

create requirejs-config.js file inside base folder instead of adminhtml folder,

var config = {
  "map": {
    "*": {
      "Magento_Ui/templates/grid/filters/filters": 
          "<Namespace>_<Module>/template/grid/filters/filters"
    }
  }
};

Remove html from templates defination

Also create template folder in your module inside base directory not use adminhtml directory,

 

New Folder Path:

<Namespace>\<Module>\view\base\web\template\grid\filters\filters.html

 

Run command,

php bin/magento setup:upgrade
php bin/magento setup:static-content:deploy

 

I have updated my answer.

 

if issue resolved, Click Kudos/Accept as solutions.

 

 

If Issue Solved, Click Kudos/Accept As solutions. Get Magento insight from
Magento 2 Blogs/Tutorial

Re: override base template file in adminhtml [Magento-Ui backend]

Hi,

 

i tried as u suggest but not working 

 

My requirejs config file in following path

<Namespace>\<Module>\view\adminhtml\requirejs-config.js

is it correct?

Re: override base template file in adminhtml [Magento-Ui backend]

Sorry my requirejs config file in following path

 

<Namespace>\<Module>\view\base\requirejs-config.js

 

But its not working.

 

Re: override base template file in adminhtml [Magento-Ui backend]

Thanks Its working as you suggest.

We need one small change in our requirejs-config.js in our base folder

 

Magento_Ui/templates is mapped to ui/template in Magento\vendor\magento\module-ui\view\base\requirejs-config.js

 

So we need to remap from Magento_Ui/templates/grid/filters/filters to ui/template/grid/filters/filters

Re: override base template file in adminhtml [Magento-Ui backend]

Hi Rakesh,

 

i successfully override base filter template filters.html file as you suggest

but i have found one issue that its override all grids in product catolog, customers, sales order etc.

 

i want to override file only for my module.

 

https://community.magento.com/t5/Programming-Questions/Added-a-new-button-in-new-module-grid-but-dis...

 

Thanks.

Re: override base template file in adminhtml [Magento-Ui backend]

How to remap from Magento_Ui/templates/grid/filters/filters to ui/template/grid/filters/filters?

Re: override base template file in adminhtml [Magento-Ui backend]

I encountered this issue for a similar file today (ui-select-optgroup.html) and fixed it using this similar code:

 

For anyone attempting this in 2.4+

1. (Please note the smallcase "ui/template")

create requirejs-config.js file inside base folder instead of adminhtml folder,

var config = {
  "map": {
    "*": {
      "ui/template/grid/filters/filters.html": 
          "<Namespace>_<Module>/template/grid/filters/filters.html"
    }
  }
};

 

2. 
Create overriden file  at   <Namespace>_<Module>/view/base/web/template/grid/filters/filters.html

 

3. Flush cache, and if module not installed then run setup:upgrade, setup:di:compile and deploy static content