yadcf-选择-将多个值拆分到单元格中的单独行 [英] yadcf - Select - Split multiple values onto separate lines in cell

查看:50
本文介绍了yadcf-选择-将多个值拆分到单元格中的单独行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在datatables.js上使用yadcf来填充和过滤列国家列表.选择内容包含国家/地区的唯一值,例如:

I am using yadcf on datatables.js to populate and filter a column Select e.g. a list of Countries. The select contains unique values for country such as:

奥地利

法国

意大利

美国

英国

一条记录可以具有国家/地区"的多个值.例如,一条记录可能包含美国"和英国".国家在单元格中显示如下:

A record can have multiple values for Country. For example a record might have "USA" and "UK". The countries display in the cell like this:

美国,英国

我希望国家/地区"的值显示在单元格中的不同行上,如下所示:

I want the values for Country to display on separate lines within the cell, like this:

美国

英国

有可能这样做吗?

推荐答案

您可以使用 text_data_delimiter:'< br>',只需确保您的< td> 单元格,在此处查看实时示例

You could use the text_data_delimiter: '<br>' just make sure you got no white spaces in yout <td> cell, see live sample here

代码段:

$(document).ready(function(){
  oTable = $('#example').dataTable().yadcf([
    {
      column_number : 0,
      text_data_delimiter: '<br>'
    }]);
});

HTML:

  <table cellpadding="0" cellspacing="0" border="0" class="display" id="example">
    <thead>
      <tr>
        <th>Some Data</th>
        <th>More Data</th>
        <th>Yes / No</th>
        <th>Values</th>
        <th>Tags</th>
      </tr>
    </thead>
    <tbody>
      <tr class="odd gradeX">
        <td>One<br>Two</td>
        <td>More Data 11</td>
        <td>Yes</td>
        <td>a_value,b_value</td>
        <td><span class="label lightblue">Tag1</span><span class="label lightblue">Tag2</span></td>
      </tr>
      <tr class="even gradeC">
        <td>Three<br>Four</td>
        <td>More Data 22</td>
        <td>No</td>
        <td>b_value,c_value</td>
        <td><span class="label lightblue">Tag1</span><span class="label lightblue">Tag3</span></td>
      </tr>      
    </tbody>
  </table>

这篇关于yadcf-选择-将多个值拆分到单元格中的单独行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆