Search code examples
jquerydatatablesyadcf

yadcf external filter dropdown always selected


Im not able to figure this one out. Why are the dropdowns marked as blue after i select an item? Is this a bug? The dropdown is generated by yadcf which is a plugin for jquery datatables. Am i missing something?

Example code: http://plnkr.co/edit/kpQabGuM6HYRPiI1Av1E?p=preview

Example picture: https://i.sstatic.net/fTXnF.jpg

$(document).ready(function() {
    var table = $('#example').DataTable({
        "bLengthChange": false
    });

    yadcf.init(table, [
        {
            column_number: 1,
            filter_type: "select",          
            filter_container_id: "ddl",
            filter_delay: 500,
            filter_reset_button_text: false,
            style_class:"form-control"          
        },
        {
            column_number: 2,
            filter_type: "select",
            filter_delay: 500,
            filter_reset_button_text: false
        }
    ]);
});

Solution

  • It is not a bug, it's a feature!

    As you can see inside of jquery.dataTables.yadcf.css file, there is a part;

    .inuse, .ui-slider-range .inuse, .yadcf-filter-range-number-slider .inuse {
        background: #8BBEF0;
    }
    

    If you don't want this blue color, just override this with white color in your code.

    <style>
    .inuse, .ui-slider-range .inuse, .yadcf-filter-range-number-slider .inuse {
        background: #FFF;
    }
    </style>
    

    You can see the working example here: Plunker