2

I want to know if its possible to get the rows with empty fields on this columns. I have a fiddle to explain this.

At first column (Status) I have three values (ON, OFF, (EMPTY)). My problem is to get the rows with empty values (Same row as PR00000003, PR00000005) selecting empty value on the filter.

Thanks in advance.
mgutbor
  • 103
  • 1
  • 11

1 Answers1

2

Since there seems to be some sort of issue with yadcf/select2 and empty string for filtering I can suggest the following solutions:

1) Use regex (see this jsfiddle) -

    var oTable = $('#example').DataTable();

    yadcf.init(oTable, [
        {
            column_number: 0,
            filter_type: 'multi_select',
            append_data_to_table_data: 'before',
            data: [ {value:'^$', label:'Empty' }], 
            filter_match_mode: 'regex',
            select_type: 'select2'
    }]);

2) Use datatables HTML5 data-* attributes ,

3) Use Chosen plugin (IMO Select2 fits datatables/yadcf better) instead of select2 see jsfiddle sample

        var oTable = $('#example').DataTable();

        yadcf.init(oTable, [
        {
            column_number: 0,
            filter_type: 'multi_select',
            append_data_to_table_data: 'before',
            data: [ {value:' ', label:'Empty' }], 
            filter_match_mode: 'exact',
            select_type: 'chosen'
        }]);

always bet on yadcf

Daniel
  • 36,833
  • 10
  • 119
  • 200
  • 1
    Really thanks for your help again, Daniel. As other solutions, this works. – mgutbor Feb 06 '17 at 07:50
  • Hi again and thanks. I have a new question about that. Will be possible to filter the empty fileds on filter_type: 'text' ??? Here is my [fiddle](https://jsfiddle.net/mgutbor/m26jzxsf/) and my explanation: I want to have any possiblities to get the empty field on column PROJECT (Row with Status=ADD and RFC Status=Accepted). Thanks again in advance. – mgutbor Feb 06 '17 at 11:01
  • 1
    you can try the `exclude` option, see this https://jsfiddle.net/vedmack/m26jzxsf/15/ filter for *PR* and check the *not* , if you will find a way to filter for empty string with datatables api let me know and I will try to add it to yadcf – Daniel Feb 06 '17 at 11:15
  • Really thanks again for this one. I think with exclude option will be enough. – mgutbor Feb 06 '17 at 11:20
  • @Daniel How would you do the same for a regular yadcf Select2 (not multi)? – OverflowingTheGlass Mar 30 '18 at 20:12