thansen-solire / datatables-light-columnfilter

DEPRECATED see https://github.com/polinome/datatables-lightcolumnfilter
12 stars 9 forks source link

filter `select` not working with false or 0 #22

Open morteza-gho opened 6 years ago

morteza-gho commented 6 years ago

I'm using Angular datatable in Server side processing mode(Ajax) And use Light Column Filter plugin to filter data in each columns.

HTML

<table datatable dt-options="dtOptions" dt-columns="dtColumns"></table>

Datatable config

DTOptionsBuilder.dtOptions = DTOptionsBuilder.fromSource()
        .withOption('processing', true)
        .withOption('serverSide', true)
        .withDataProp('data')
        .withPaginationType('full_numbers')
        .withOption('ajax', {
             url: '/products',
             type: 'GET',
             headers: {Authorization: 'Bearer ' + $auth.getToken()},
             error: function (xhr, error) {
                $log.error(error);
             },
             complete: function (data) {
                $log.log('Done');
             }
        })
        .withLightColumnFilter({
             '0': {type: 'text'},
             '1': {
                type: 'select',
                values: [
                   { value: 1, label: 'Yes'},
                   { value: 0, label: 'No'}
                ]
             }
        });

create columns

$scope.dtColumns = [

        DTColumnBuilder.newColumn('title').withTitle('title').renderWith(function (data) {
           return data;
        }),
        DTColumnBuilder.newColumn('for_sale').withTitle('for sale').renderWith(function (data) {
           return data; // 0, 1 or true, false
       })
]

Filter with type:'text' is correct and work fine. But filter with type:'select' is incorrect! In other hand when I select Yes filter is work and data filtered, But when select No result is empty.

I test select value with 0,1 and true,false. In both ways, option with true or 1 value is correct but option with 0 or false value is incorrect.

In your opinion, where is the problem?

stephane-monnot commented 6 years ago

Did you check the data sent to the server ? Maybe a sql query issue ?

morteza-gho commented 6 years ago

No, Data id OK.