custom filter by salary
custom filter by salary
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]
}
This discussion has been closed.
Answers
Hi @andreinariera96 ,
Take a look at this version of your example.
What I have done here is move the
columns.searchPanes.showto the first column definition for column 5. This wasn't being applied in the second column definition block because of howcolumnDefsprioritises the definitions - the docs explain this further.Thanks,
Sandy