【问题标题】:Filtering with html content过滤 html 内容
【发布时间】:2015-12-03 04:37:10
【问题描述】:

我正在尝试在包含 html 内容的列上放置一个选择过滤器。

过滤器会找到 html 字符串的 id,但是一旦我在过滤器中选择了一个值,表格就不会显示任何记录。

请参见此处的示例: http://live.datatables.net/rabesuta/1/edit?html,js,output

相关td内容

<td><i id="Yes" class="fa fa-circle" style="color:green;font-size:20px;"></i></td>

yadcf 设置:

 yadcf.init(table,[   
         {
           column_number: 0, 
           column_data_type: 'html', 
           html_data_type: 'id'            
         }
  ]);

【问题讨论】:

    标签: datatables yadcf


    【解决方案1】:

    它实际上与 yadcf 无关,而是与数据表本身有关,

    如果您将使用单词 NoYes 提供全局数据表过滤器,它不会向您显示任何结果 - 因为它似乎没有查看 html 属性,

    所以你可以做的是在你的内部放置一个隐藏的 html 元素(包含你想要的 serach 值,像这样

    <td>
        <i id="No" class="fa fa-circle" style="color:red;font-size:20px;">
            <span class="hide">No</span>
        </i>
    </td>
    

    使用以下 css

    .hide {
      display: none;
    }
    

    一切都会按预期进行,see working sample

    您甚至可以通过从 html 中删除 id 并使用更简单的 yadcf 设置来减少 html 和 yadcf 设置,请参阅 working sample N#2

    相关代码:

    <td>
        <i class="fa fa-circle" style="color:red;font-size:20px;">
            <span class="hide">No</span>
        </i>
    </td>
    
    
     yadcf.init(table,[   
             {
               column_number: 0, 
               column_data_type: 'html'
             }
      ]);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-07-30
      • 2014-05-01
      • 1970-01-01
      • 2015-11-08
      • 1970-01-01
      • 2012-07-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多