on 07-15-2009 8:02 AM
Hi all,
I used the following blog /people/kapil.kamble/blog/2006/12/21/how-to-get-ready-made-filter-for-your-web-dynpro-table-with-minimal-coding to implement TableFilter succesfully.
Thanks to Kapil for his wonderful blog.
Now I would like to enhance the Filter mechanism provided in the blog.
Currently S* shows all the rows matching s but I would like to use just S to filter the rows starting with S.....
i.e., I want to remove asterik(*) for filter functionality and use space instead of that.
Any pointers to enhance Kapils TableFilter.java would be really helpful.
Thaks in advance
Santhosh
Edited by: Santhosh Edla on Jul 15, 2009 10:02 AM
Hi,
Do you really want to use space as a part of the filter string? Maybe you should just use "S" if you want to filter for rows starting with S and not use "S<SPACE>".
To get this functionality with the version of TableFilter class that you are using you will need to modify the code a bit. In the refineFilterString function make the following change:
if ( ! filterString.equalsIgnoreCase(".*") )
{
if(filterString.indexOf('*')>=0)
{
filterString = filterString.replaceAll("\\*","\\.\\*");
}
else
{
//filterString = ".*" + filterString + ".*"; //original code
filterString = filterString + ".*"; //modified code
}
if(!filterString.endsWith("*") && !filterString.startsWith(".*") && (filterString.indexOf('*')> 0))
{
filterString = ".*" + filterString + ".*";
}
}
One caveat, after making these changes if you want it to match the filter string you enter anywhere in the column values you will need to use "*<your filter string>".
Regards,
Satyajit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Satyajit,
I have used your code and able to filter the rows with out typing the star.
But I did not understand the caveat you mentioned at the last.Could you please explain the same
One caveat, after making these changes if you want it to match the filter string you enter anywhere in the column values you will need to use "*<your filter string>".
Actually if I use "*<filter string>" It is not filtering properly. But by directly using "<filter string>",it works properly.
I did not understand what u were trying to say with the above line.
Do you mean the logic provided by you is not fully functional or has some issues.Please let me know
Thanks a lot for the help
Santhosh
Hi,
Let me explain - the original code (provided in the blog you referred to) would match "Sine" as well as "Cosine" if you entered "S" as the filter string. The original code matched "S", the filter string anywhere in the individual column values. But you wanted it to match only strings starting with "S" which would be "Sine" in this case. Hence we modified the code. Now it correctly matches "Sine" only for the filter string "S".
But now if you want to go back to the original functionality (of matching the filter string anywhere and not only strings starting with the filter) then you will have to use "<STAR><filter><STAR>". That's what I meant.
Regards,
Satyajit
Hi,
in your code u give space instead of "*"
see the code below.
In all places u change the code.
public String refineFilterString (String filterString)
{
if ( ( null == filterString ) || ( 0 >= filterString.length() ) )
{
filterString = ".space"; //show All
}
if ( ! filterString.equalsIgnoreCase(".space") )
{
if(filterString.indexOf('space')>=0)
{
filterString = filterString.replaceAll("
space","
.
space");
}
else
{
filterString = ".space" + filterString + ".space";
}
if(!filterString.endsWith("space") && !filterString.startsWith(".space") && (filterString.indexOf("space")> 0))
{
filterString = ".space" + filterString + ".space";
}
}
return filterString;
}
Regards,
Sunaina Reddy t
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi santhosh,
tablefilter.java
if (refinedFilter.equals(".*"))
in this if condition instead of ".*" place space.
Regards,
Sunaina Reddy T
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sunaina,
Thaks for the reply. I am not able to locate where us asked me to change?
Here is the code snippet of refienstring. Let me know the line of code to be modified
public String refineFilterString (String filterString)
{
if ( ( null == filterString ) || ( 0 >= filterString.length() ) )
{
filterString = ".*"; //show All
}
if ( ! filterString.equalsIgnoreCase(".*") )
{
if(filterString.indexOf('*')>=0)
{
filterString = filterString.replaceAll("\\*","\\.\\*");
}
else
{
filterString = ".*" + filterString + ".*";
}
if(!filterString.endsWith("*") && !filterString.startsWith(".*") && (filterString.indexOf('*')> 0))
{
filterString = ".*" + filterString + ".*";
}
}
return filterString;
}
Thanks
Santhosh
User | Count |
---|---|
101 | |
13 | |
13 | |
11 | |
11 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.