在Magento2管理目录产品网格中添加颜色

使用Magento 2.2,管理网格。我想在目录产品的“状态”栏中添加样式。

chongqingwangjing 回答:在Magento2管理目录产品网格中添加颜色

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

 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

本文链接:https://www.f2er.com/3060791.html

大家都在问