【问题标题】:Add Colors In Magento2 Admin Catalog Product Grid在 Magento2 管理目录产品网格中添加颜色
【发布时间】:2019-11-21 04:58:51
【问题描述】:

使用 Magento 2.2,管理网格。我想在 Catalog 产品的 Status 列中添加样式。

【问题讨论】:

    标签: grid product magento2 catalog


    【解决方案1】:

    请复制这些文件并将它们移动到您的主题中。 在下面的文件中添加此代码

     attr="style: getColorStyle($row())"
    

    vendor/magento/module-ui/view/base/web/templates/grid/listing.html

     <tr class="data-row" repeat="foreach: rows, item: '$row'" css="'_odd-row': $index % 2" attr="style: getColorStyle($row())">
      <td outerfasteach="data: getVisible(), as: '$col'" css="getFieldClass($row())" click="getFieldHandler($row())" template="getBody()"/>
     </tr> 
    

    并在下面的文件中添加这个函数

     getColorStyle: function(row)
     {
      /*
       var jsonData = JSON.stringify(row);
       console.log(jsonData);
      */
      if(row['status'] == '1'){
       styles =  'background: #fefafa';
      }else{
       styles =  'background: #6a0dad';
      }
      return styles;
     }
    

    vendor/magento/module-ui/view/base/web/js/grid/listing.js

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-08-29
      • 1970-01-01
      • 1970-01-01
      • 2016-10-04
      相关资源
      最近更新 更多