JQuery DataTables filter column with comparison operators?

The 3 steps needed should be: create the UI write a filtering function setup events to redraw the DataTable when the UI changes First create the UI. For me, the easiest way to capture the user's intent is to use a select box where the user can pick which comparison operator he wants to use: = >= 0 &&! IsNaN(parseInt(value, 10))) { value = parseInt(value, 10); var row_data = parseInt(aDatacolumn_index, 10); switch (comparator) { case 'eq': return row_data == value?

True : false; break; case 'gt': return row_data >= value? True : false; break; case 'lt': return row_data Then you can parse the input in a filter function like this: $.fn.dataTableExt.afnFiltering. Push( function( oSettings, aData, iDataIndex ) { var filter = $('#filter').val().

Replace(/\s*/g, ''); var row_data = aData3 == "-"? 0 : aData3*1; if (filter. Match(/^\d+$/)) { var num = filter.

Match(/\d+/); return row_data > num? True : false; } else if (filter. Match(/^\d+$/)) { var num = filter.

Match(/\d+/); return row_data! = num? True : false; } else if (filter.

Match(/^\d+$/)) { var num = filter. Match(/\d+/); return row_data == num? True : false; } else if (filter.

Match(/^\d+-\d+$/)) { var num1 = filter. Match(/^\d+/); var num2 = filter. Match(/\d+$/); return (row_data >= num1 && row_data = and and I've also once again attached the event listener to a free floating input text box.

I've tried this with a basic DataTable and it works. You would need to attach the behavior to those text boxes at the bottom of your columns, but I'm not sure how you got them there - I've never done that with a DataTable.

Very nice summary! However, I was wondering if there was a way to parse the comparison operator directly from the filter inputs at the bottom of the table and then pass the rest to the comparison filter. I'll edit my post to include an image.

I'm thinking that I would have to change function that is called on the keyup to look for an operator. – DTing Mar 30 at 21:13 Can you post the JS that you are using to create the DataTable? – ttubrian Apr 1 at 14:47 I added input parsing to the answer.

If you can show how you are achieving the filter boxes at the bottom of the image then maybe I can help you tie in my filter function. I've never had those at the bottom of one of my DataTables (I've only created very simple DataTables). I've noticed the dataTables.

HtmlColumnFilter. Js plugin mentioned in some documentation, but I can't find where to actually download that script. – ttubrian Apr 1 at 18:01 Thanks so much for the help.

I basically followed the instructions here for the column filtering. Datatables. Net/examples/api/multi_filter.

Html – DTing Apr 1 at 18:19 1 Ah. I never found that page. Let me take a look and get back to you.

– ttubrian Apr 1 at 18:28.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions