Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I'm trying to make a filter with passing multiple values for the filter but have only a single return.

field: 'name',
    filter: {
       condition: function(searchTerm, cellValue) {
        var strippedValue = (searchTerm).split(';');
        //console.log(strippedValue);
        for (i = 0; i < strippedValue.length; i++){
          if (cellValue.indexOf(strippedValue[i]) == -1)
            return false;    
          return true;
        }
        //return cellValue.indexOf(strippedValue) >= 0;
      }
    }, headerCellClass: $scope.highlightFilteredHeader

find the test code here http://plnkr.co/edit/UVDWfucjclXl4Ij9Ylm7?p=preview

share|improve this question
    
What are you trying to accomplish ? what is the use case where you need more than one value for the filter ? and how are you planning to put in multiple values for say the name for example ? –  Mostafa Torbjørn Berg May 6 at 19:40
    
I'm working on a contract management project which was created demand to make multiple filters in the search fields Ex: filter by "acrediaria; DNIT "must return values that contain the client" acrediaria "or" DNIT ". –  Bruno Costa May 7 at 16:04
    
This is solvable by using regex expressions which is already supported in the code you linked –  Mostafa Torbjørn Berg May 9 at 14:27

1 Answer 1

up vote 0 down vote accepted

Resolved, I made some adjustments to improve the code as well.

 condition: function(searchTerm, cellValue) {
    var separators = ['-', '/', ':', ';', ','];
    var strippedValue = searchTerm.split(new RegExp(separators.join('|'), 'g'));
    var bReturnValue = false;
    //console.log(strippedValue, "teste");
    for(iIndex in strippedValue){
        var sValueToTest = strippedValue[iIndex];
        sValueToTest = sValueToTest.replace(" ", "");
        if (cellValue.toLowerCase().indexOf(sValueToTest.toLowerCase()) >= 0)
            bReturnValue = true;
    }
    return bReturnValue;
}

Look code in link: http://plnkr.co/edit/UVDWfucjclXl4Ij9Ylm7?p=preview

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.