Okay
  Public Ticket #877450
Problem with checkbox filters
Closed

Comments

  •  2
    Nordine started the conversation

    Hi. I've been working on a website with my colleague, Nordine Benhamari, who has already been in touch with you some time ago. Our web page using wpDataTables is here: http://www.thanetvolunteerbureau.co.uk/search-volunteer-opportunities/

    As you can see, our table allows users to filter opportunities by three fields: location, interests/skills, and age (whether suitable for under 18s). But users can only select one value at a time from these fields. We really want users to be able to select multiple values for the first two fields, e.g. to show all opportunities located in Broadstairs OR Ramsgate. Using checkboxes instead of selection menus would work if we had only one value in each field. But we have multiple values. For example, an opportunity may be located in Margate AND Broadstairs, in which case the location field would contain both values separated by a comma: "Margate, Broadstairs".

    Your selection filters can cope with multiple values separated by a comma, because they seem to search for the filter value anywhere in the field, so filtering on "Broadstairs" will match with "Margate, Broadstairs". But your checkbox filters seem to only match against the whole field, so filtering on "Broadstairs" doesn't match with "Margate, Broadstairs". That means I can't use checkboxes for my first two filters.

    I'm hoping you'll tell me that I've misunderstood something, and that there is in fact a way to do what I want. If not, perhaps you could consider making this possible in a future version.

    Best wishes,

    Richard Wein.

  • [deleted] replied

    Hi Richard and Nordine,
    Thank you for your purchase.

    Please provide me a temporary WP-admin login for your site, so we could log in and take a look ‘from the inside’. It is possible to accomplish with little customization of the plugin. We do not interfere with any data or anything else except for the plugin (in case that’s a production version of the site), and of course we do not provide login data to third party. You can write credentials here just mark Private Replay so nobody can see it except us.

  •   Nordine replied privately
  • [deleted] replied

    Hi Richard and Nordine,

    Please try now. I have set filters to checkbox and it's is showing multiple checked values.

    If you like our plugin and support please rate our plugin at CodeCanyon on this link. It means a lot to us. Thanks.

  •  2
    Nordine replied

    That's great, Milos. Thanks very much.

    For now I've switched the live page back to the way it was, using selection menus. Before going live with the change I'd like to test it more thoroughly, and also adjust the layout of the page. I have a draft page that I use for testing: http://www.thanetvolunteerbureau.co.uk/?page_id=2076&preview=true

    I have a further question. Did you change the code of the plug-in? If so, I'm concerned that the change will be lost the next time we update to a new version. What would be the best way to handle that?

    I'll rate the plug-in very soon, but must rush now.

    Regards,

    Richard Wein.

  • [deleted] replied

    Hi Richard and Nordine,

    Yes, I changed the code. For version that you have it's a little bit different then in future releases.

    For version 1.6.1 in file ../161/wp-content/plugins/wpdatatables/assets/js/jquery-datatables/jquery.dataTables.columnFilter.js on line 618 I have commented line:

    search = search + '^' + $(this).val() + '$' + or;
    

    and uncommented line above it:

    search = search  + $(this).val()  + or;

    In future releases, in same file, you will have to find and comment (or delete) line:

    search = search + '^' + $(this).val().replace(/\+/g,'\\+') + '$' + or;
    

    and to uncomment line above it:

    search = search + '(?=.*' + $(this).val().replace(/\+/g,'\\+') + ')';

    Please note that if you are making changes in file jquery.dataTables.columnFilter.js you will have to uncheck checkbox on wpDataTables settings page Use minified wpDataTables Javascript.

    In version that you have installed I made changes in file jquery.dataTables.columnFilter.min.js and because of that I didn't uncheck that option.