How To Filter On Input Value Text
How To Filter On Input Value Text
roadjan
Posts: 22Questions: 6Answers: 0
Hi,
I am using buttons for quick filters on my datatable. It works for columns containing text using this code. How do I filter based on the value text of an input in the column (i.e. the button text of a button in the column).
function filterColumnC( value ) {
table.column(3).search( value ).draw();
}
$('button#quote').on('click', function () {
filterColumnC('quote');
})
Answers
Do something similar. Create an event handler for the buttons in the table. Use delegated events, like this example. In the event handler get the clicked button's text and use
column().search()
.Kevin
Sorry, I am not being clear. My code searchs column#3 for a 'value' which is passed to the function, in this case the value is 'quote'. How do I alter the function to look for the text value of the button, rather than then text 'quote'. It is not recogising the button value 'Create Invoice' as text, and therefore returns no results.
Use standard jQuery methods to get the text. Something like this maybe?
Kevin