custom filter by salary

custom filter by salary

andreinariera96andreinariera96 Posts: 2Questions: 2Answers: 0
edited July 2021 in SearchPanes

http://live.datatables.net/xejidida/2/edit?html,js,output
http://live.datatables.net/xejidida/2/watch?html,js,output

Hi! I am trying to do a custom filter for the money value of a column, using the extension "searchPanes". But I can't find the right way to do it.

I leave at the beginning the links to the example that I made.

Does anyone know the correct way to make a custom filter of this type?

columnDefs:[
                    {
                        data: "salary",
                        render: $.fn.dataTable.render.number(',', '.', 0, '$')
                    },
                    {
                        searchPanes: {
                            options: [
                                {
                                    label: 'Under 100,000',
                                    value: function(rowData, rowIdx) {
                                        return rowData[5] < 100000;
                                    }
                                },
                                {
                                    label: '100,000 to 500,000',
                                    value: function(rowData, rowIdx) {
                                        return rowData[5] <= 500000 && rowData[5] >= 100000;
                                    }
                                },
                                {
                                    label: '500,000 to 1,000,000',
                                    value: function(rowData, rowIdx) {
                                        return rowData[5] <= 1000000 && rowData[5] >= 500000;
                                    }
                                },
                                {
                                    label: 'Over 1,000,000',
                                    value: function(rowData, rowIdx) {
                                        return rowData[5] >= 1000000;
                                    }
                                },
                            ]
                        },
                        targets: [5]
                    }

Answers

Sign In or Register to comment.