koalyptus / TableFilter

A Javascript library making HTML tables filterable and a bit more :)
https://www.tablefilter.com
MIT License
323 stars 95 forks source link

Identify when in 'Filter Mode' #771

Closed Pajservices closed 4 years ago

Pajservices commented 4 years ago

I have a long table that contains a Check box on each line for selection, and some code that allows consecutive check boxes to be selected by 'Click First - Hold Shift - Click Last'.

When the table is filtered though, the 'hidden' lines between the start and end are also selected (which I can understand) - so I have tried to enhance my code to determine if a line is 'filtered out /hidden'. I also have code that runs through the table and counts the Checks, and tried to determine which are filtered so as to ignore them but can't seem to find which attribute to check for.

Is there any way of knowing when in 'filtered mode' or identifying which are hidden.

I have attached the code which 'ticks' all in between, which I need to amend to ignore the 'hidden' ones

// Code used to allow SHIFT Click on boxes and tick them all between (chkbox is id of the chkbox field ) var lastChecked = null; $(document).ready(function() { var $chkboxes = $('.chkbox'); $chkboxes.click(function(e) { if(!lastChecked) { lastChecked = this; return; }

          if(e.shiftKey) {
             var start = $chkboxes.index(this);
             var end = $chkboxes.index(lastChecked);
             $chkboxes.slice(Math.min(start,end), Math.max(start,end)+ 1).prop('checked', lastChecked.checked);
          countCheckboxes ();
          }

          lastChecked = this;
       });
});`
koalyptus commented 4 years ago

Hi @Pajservices,

TableFilter exposes an API to know which rows are filtered, tf.isRowDisplayed(rowIndex) or which rows are valid tf.isRowValid(rowIndex), tf being the TableFilter instance:

Those helper methods should help you in the checkboxes behaviour logic.

Cheers

Pajservices commented 4 years ago

Thanks so much

Regards

Phil Jones

From: koalyptus notifications@github.com Sent: 09 June 2020 10:28 To: koalyptus/TableFilter TableFilter@noreply.github.com Cc: Phil Jones phil@pajservices.co.uk; Mention mention@noreply.github.com Subject: Re: [koalyptus/TableFilter] Identify when in 'Filter Mode' (#771)

Hi @Pajservices https://github.com/Pajservices ,

TableFilter exposes an API to know which rows are filtered, tf.isRowDisplayed(rowIndex) or which rows are valid tf.isRowValid(rowIndex), tf being the TableFilter instance:

Those helper methods should help you in the checkboxes behaviour logic.

Cheers

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/koalyptus/TableFilter/issues/771#issuecomment-641157223 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AGHHW6DJYE575NHROC3ZL4TRVX6ALANCNFSM4LFPUG7Q . https://github.com/notifications/beacon/AGHHW6BUKUW4N5NQ7FOJS3LRVX6ALA5CNFSM4LFPUG72YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEY3UQZY.gif