Filtering with regex

Filtering with regex

mnovakovicmnovakovic Posts: 5Questions: 0Answers: 0
edited March 2009 in General
Hi, i would like to implement AND option with fnFilter. How to do that?

I am representing a list of projects in datatable. One project-one row. Each project has some features. So i took id's of features for each project and created CSV string from it. This is hidden column for each project.

I have list of checkboxes with all features. How to implement filtering with this. (List only those products that have all of selected features)

For example one project has this hidden-column: 'feature-1;feature-2;feature-3' and i want to apply filter for feature-1 AND feature-2.

I have looked into source code of a project and based on regex this should work table.fnFilter('feature-1 feature-2'), but ti doesn't :((

Please help.

Replies

  • allanallan Posts: 61,451Questions: 1Answers: 10,055 Site admin
    Hi mnovakovic,

    You are right, it should 'AND' automatically. I don't see any reason why that you have wouldn't work, and with a quick test here, it does appear to do what is expected. Could you post and example page which fails as you describe?

    Thanks
    Allan
  • mnovakovicmnovakovic Posts: 5Questions: 0Answers: 0
    Hi,

    you have that cool regexp string builder (simulating AND instead of ' ') ONLY if your column parameter is not defined (searching on all columns). But for some reasons this is not working for me.

    I set searching on specific column, where this "AND" automatic regexp builder is not created. Actually, you are not splitting on ' ' and creating this regexp, but only search for whole string - param. So i created whole regexp string as you did in search on all columns, and set third param in fnFilter to false and i got what i needed :)).

    It took me a lot of time, but it finally worked :D
  • allanallan Posts: 61,451Questions: 1Answers: 10,055 Site admin
    Hi mnovakovic,

    Good to hear you got what you wanted working in the end!

    You are quite right - I don't use my regular expression for single columns. I had kind of been assuming that individual column filtering would be only on one word, but that appears to be a bit of a weak assumption on my part. At the same time the global filtering takes all of the rows and will match the words in any order. Sorry I wasn't quite clear that this was what you were looking for on a single column. Love that regex switch :-)

    Allan
This discussion has been closed.