【发布时间】:2019-11-24 16:10:42
【问题描述】:
为我构建的数据表拥有这个 html 和 js 代码
<button class="test">test</button>
<table id="example2" class="display table " width="100%">
<thead>
<tr>
<th>Code</th>
<th>Email</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<tr>
<td>abc12345</td>
<td data-search="derrick1@gmail.com"><input name="email[]" id="row-email-0" value="derrick1@gmail.com" /></td>
<td>N/A</td>
</tr>
</tbody>
</table>
<script>
var theTable = $('#example2').DataTable({
"ordering": false
});
theTable.row.add([
'abc432',
'<input name="email[]" id="row-email-\' + rowIndex + \'" value="" />',
'N/A'
]).draw(false)
</script>
如何在datatable的row.add方法上设置data-search属性?
【问题讨论】:
-
请澄清您的问题。您想使用自定义搜索输入向现有表中添加一行吗?搜索栏包含在零配置中:datatables.net/examples/basic_init/zero_configuration.html
-
嗨@Twisty,我需要通过数据表row.add方法对电子邮件列进行数据搜索,其中电子邮件列与输入字段有关。如果未设置数据搜索,则默认搜索栏无法搜索电子邮件列。
标签: javascript jquery datatables datatables-1.10