您可以使用datatables HTML5 data-* attributes的,然後告訴yadcf依靠與使用html5_data
此DT功能,使您的td
看起來像
<td data-search="assigned"><img src='http://lab.onclud.com/psm/redcircle.png' class='asgn'></td>
和yadcf INIT看起來像
var oTable = $('#example')。數據表();
yadcf.init(oTable, [
{
column_number: 0,
html5_data: 'data-search',
filter_match_mode: 'exact',
data: [{
value: 'assigned',
label: 'Assigned'
}, {
value: 'notassigned',
label: 'Not assigned'
}]
}]);
請注意,我用filter_match_mode: 'exact',
因爲我以前data-search="notassigned"
和data-search="assigned"
,由於包括內部的分配字notassigned我不得不告訴yadcf執行確切搜索,這可以,如果你避免將使用獨特的搜索項在data-search=
屬性,
See working jsfiddle
Anoth由kthorngren from datatables forum介紹呃解決方法是使用下面的DT初始化代碼
var oTable = $('#example').DataTable({
columnDefs: [{
targets: 0,
render: function(data, type, full, meta) {
if (type === 'filter') {
return full[0].search('asgn') >=1 ? "assigned" : full[0].search('notasg') >= 1 ? "notassigned" : data
} else {
return data
}
}
}],
});
和yadcf的init(除去html5_data
)
yadcf.init(oTable, [
{
column_number: 0,
filter_match_mode: 'exact',
data: [{
value: 'assigned',
label: 'Assigned'
}, {
value: 'notassigned',
label: 'Not assigned'
}]
}
]);
third option - look here
你必須明白,你對更新原來的問題改變了基於你原來的問題和原來的jsfiddle例子給出的解決方案,這使你的更新不是一個真正的upd吃了一個新的問題 – Daniel