Reputation: 1138
I am trying to remove a select option from an external filter select field using yadcf 0.8.9. In yadcf 0.6.9 I was able to remove this option before the call to exFilterColumn()
, but in 0.8.9 I must remove the option after the call.
Actually what I am trying to do is force the select to have some value which is in the table column, and to have the table filtered on that value
I can't seem to figure out how to remove the unfiltered possibility from the select and have the table filtered on the chosen value (either the first or one I am picking in the code). In 0.6.9, I removed '-1' value option, but this doesn't seem to work in 0.8.9.
Advice?
See http://codepen.io/louking/pen/ZWYpGM vs http://codepen.io/louking/pen/zqxBLL
html:
<div>
<span id='yadcfext'></span>
</div>
<table id=tbl>
<thead>
<tr>
<th>col0</th>
<th>col1</th>
<th>col2</th>
</tr>
</thead>
<tbody>
<tr>
<td>a0</td>
<td>b0</td>
<td>c0</td>
</tr>
<tr>
<td>a1</td>
<td>b1</td>
<td>c1</td>
</tr>
</tbody>
</table>
remove option before exFilterColumn
var dt= $('#tbl')
.dataTable()
.yadcf([
{column_number: 0,
filter_container_id: 'yadcfext'}
]);
var selectfilter = '#yadcfext';
$(selectfilter + ' option[value="-1"]').remove();
yadcf.exFilterColumn(dt, [[0,'a1']]);
remove option after exFilterColumn()
var dt= $('#tbl')
.dataTable()
.yadcf([
{column_number: 0,
filter_container_id: 'yadcfext'}
]);
yadcf.exFilterColumn(dt, [[0,'a1']]);
var selectfilter = '#yadcfext';
$(selectfilter + ' option[value="-1"]').remove();
Upvotes: 1
Views: 436
Reputation: 37061
Sounds like a new feature :)
So since 0.9.0.beta.9 you can use the ommit_default_label option, see your codepen in action
* omit_default_label
Required: false
Type: boolean
Default value: false
Description: Prevent yadcf from adding "default_label" (Select value / Select values)
Note Currently supported in select / multi_select / custom_func / multi_select_custom_func
Upvotes: 1