Click here to Skip to main content
15,667,014 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have problem regarding my Filtering of my Table. I'm using a ViewerFilter and override the select Method to fitler that Table. The Filtertext itself is entered via a Textfield.

So now to my problem. For example my table looks like the following:


In my textfield the user can enter the columnname=data1,data2 to show all rows which have either data1 or data2 as data. so in my above example if the user enters column=123,124 both rows should still be visible. The problem here is that I refresh my tableviewer after each entered character. So when the user enters column=123 the Table only shows one column. When adding ,124 to the filtertext I filter my already filtered table. So no data gets shown at the end. How can I still filter the original Tabledata?

   public boolean select(final Viewer viewer, final Object parentElement, final Object element) {
       final String filterString = filterText.getText().toLowerCase();
       if (filterString.length() == 0) { return true; }

       final mydata myData= (mydata) element;
       if (filterString.matches("columnName" + ".+")) {
       index = filterString.indexOf("columnName" + ".+");
      evaluateText(myData, filterString, i, index + tableColumnsText[i].length())

   public boolean evaluateText(final mydata data, final String filterText, final int beginningIndex) {
           subString = filterText.substring(beginningIndex, filterText.length());
           return evaluateString(data.getString(), subString);

   public boolean evaluateString(final String cellString, final String commaString) {
       int countSubstrings = 0;
       final String[] items = commaString.split(",");
       countSubstrings = items.length;

       for (final String s : items) {
           if (s.length() != 0) {
               if (!cellString.contains(s)) { return false; }
       return true;

So I tried to filter out the main components of the method. Does someone have an idea how to solve this problem?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900