Filtering and orderable false
Filtering and orderable false
![miltont](https://secure.gravatar.com/avatar/73d060945aad8cf7a94245018fcbc175/?default=https%3A%2F%2Fvanillicon.com%2F73d060945aad8cf7a94245018fcbc175_200.png&rating=g&size=120)
I have the following script:
<script>
$(document).ready( function () {
var table = $('#myTable').dataTable( {
"order":[[1,"desc"],[2,"desc"],[3,"desc"],[4,"desc"],[5,"desc"]],
"dom": '<lif<t>p>',
lengthMenu: [[100,10,25,50,-1],[100,10,25,50,"All"]],
fixedHeader: {headerOffset: 80},
columnDefs: [
{ targets: [1,2,3,7,8], className: 'dt-body-center'},
{ targets: [4,5,6,9], className: 'dt-body-right'},
{ targets: [1], render: DataTable.render.number( ',', '.' )},
{ targets: [7], render: DataTable.render.number( ',', '.', 0, '$' )}
]
});
} );
</script>
And I don't know how to include the following code inside this...
var table = $('#example').DataTable();
var filteredData = table
.column( 0 )
.data()
.filter( function ( value, index ) {
return value > 20 ? true : false;
} );
also I tried adding the following to disallow ordering and this would not work.
{
targets: [ 0, 1, 2, 3, 4, 5 ],
orderable: false
},
Any assistance would be appreciated.
Milton.
This question has an accepted answers - jump to answer
Answers
That option works here:
http://live.datatables.net/texagicu/1/edit
What are you wanting to do with the code you posted?
Please provide a test case showing the issues with details of how to replicate the problems.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin
Thanks Kevin, I added the orderable false but it didn't work and then I realized I missed a comma....This now works.
With the filter Data, I don't know where to place that code inside that same script.
I wish to filter the number of rows so that in column 3 if the value is greater than or equal to 9.
I attempted to provide a test case, but could not get that to work.
Milton.
The
filter()
is used to get a data set, matching the filter rule, that can be used in Javascript, ie, thefilteredData
variable will contain the results. It doesn't hide / show rows in the table.If you are trying to filter the table display then you will need a range search, like this example.
Are you wanting to filter the table or get a Javascript variable with filtered data?
Kevin
Thanks Kevin,
That's exactly what I required.
I had to tweak the columnDefs targets as I was getting a parameter error, but once I worked out that I was referencing too many columns I got it to work.
Really appreciate your help.
Milton.