Tuesday, October 6, 2009

I know, most of the SharePoint developers are looking for this. As everyone knows we can do partial search on data view web part by passing a parameter to it and by using the expression "contains" we can implement partial search on a field or column. But, when you come to list view web part you can't pass the parameters [There is no support for list view web part like web part parameters] and no way we can implement the partial keyword search. Today I have spent time on it to solve this problem with the help of my colleague Durga and found a wonderful way. This is giving really wonderful result and doing wild card search even on very big document libraries fast. Below are the steps I followed to solve this. [I will post detailed post on it with screen shots and nice explanation soon in this blog.]

Created an ASPX web part page in a SharePoint site.

Added two web parts to the page. One is for content editor web part and another is for list view web part of a SharePoint library or list.

Now, open the page in IE browser and add a text box, button to the content query web part.

Written simple logic to button click event of the button and reload the page with the below formatted url. The url should be of the format

Now the above url will search all the records in the given list view for the keyword "prav". So, wherever it exists in the given field name it will return all records.

Then how it is working?Generally, If you research on query strings for a list view web part, it expects some query strings to filter and sort. I am SharePoint developer and got to know the two query strings which SharePoint list view web part uses for filtering. FilterName and FilterMultiValue. So, with that my research continued and tried long time with so many operators like %, single quotes, double quotes etc… in the value of the FilterMultiValue. Finally, I tried with * character before and end of the keyword, there I succeeded. Example: *prav* to FilterMultiValue.

That’s it…. Working simply great.

With that, You are done implementing the wild card search in a column in list view web part.

Happy by doing SharePoint customization. I know, this will solve so many problems to SharePoint dev’s. Isn’t it? Please let me know if you have any questions, issues and write your valuable feedback and comments.

Will post more descriptive explanation of this post with screenshots soon in this blog. Follow me!!!

Thanks for the comment. But for my requirement, I can't use the data view web part. There are lot of differences to both web parts in rendering and implementation. For my requirement I need to use list view web part and wild card search. And more over I already mentioned in my blog post like "we can implement it in data view". :)

Hi Praveen,I have taken the same steps you have provided in your post, but is not working for me.It is not redirecting the page when i enter some string in the text box and click on the button.I have even tried editing the url directly in the browser.In my current example i have list which has a column Analyst and i want to get all the rows which contain "Holloway" in the analyst column.the url i used is "http://urlofthepage.aspx?FieldName=Analyst&FieldMultiValue=*Holloway*".Any help.

Hi there, I have corrected my post as there are minor mistakes in the url. I changed the url correctly and tested. Please try once with new url given and let me know the result. Still if you face any problem then tell me the problem. I will help you out.And automatically, the page won't refresh when you click submit button. Below is the logic to render the controls and rise the button click event and reload the page with new values. Paste the below as is in the content editor web part.

Thanks a lot for this post. We have implemented this and it works fine, except for one thing: we are using the filter on a grouped view of a list and after applying it indicates in which groups we can find the item, but all items of that group are still shown. Do you know what could be the issue here and how we could solve it?

Thanks for correcting the query string I owe you one, it is working absolutely fine. But I have one other problem when i filter i have say about 60 records and at a time I am displaying on 15 records so when i click on the next page the filter is removed and it is going to the next page of the whole list.

I have one another problem also.There are announcement's list on the same page, when i provide a filter string and redirect it the announcement's list shows a error "One or more field types are not installed properly. Go to the list settings page to delete these fields." or some times it shows no announcements inspite the announcements list has some.

To solve the issue that I had (The paging and the one with the Announcement's web part on the same page), I have created different views for the same list and while creating the views we can provide the filters for the list and that's how I solved my problem.Hope it helps.

Hi Bil Simser,Thanks for the comment. We have tried that way, but the only thing bothered me is, how to handle this while paging. The scenario is, when we want to show the data on a specific ASPX page other than allitems.aspx and using the list view web part, I want to do filter. But if results contains more than 20, the paging will appear and when page index changed all my query strings are disappears. So, how to keep them? The post went into the confusion mode with that question.

Hi there,You need to use the FilterName and FilterMultiValue or FilterField1 and FilterValue1. FilterMultiValue works with the FilterName. So, in your querystring I am not seeing any thing related to FilterName. So, try to change the querystring and let me know. I am believing if you place both formats that may not work. But, give it a try like shown below."/Lists/Career%20Map/AllItems.aspx?FilterField1=TechnicalExcellence&FilterMultiValue1=25%&FilterField2=Division&FilterMultiValue2=*DDPM;Sales*"

hi,praveen ur solution is very use full to me but i am unable to get the filter data for discussion board (LinkDiscussionTitle-->Subject) and Document library (LinkFilename-->Name).for these columns i am unable to filtering please give me suggestion.

Great Post and useful info. However, like some I ran into columns not working (throwing error) etc. This is because sharepoint has both a 'display' name and a real 'name'when it generate a list. To search you need to use the real name. Here is some JavaScript I used for a search feature on our little farm.

--------------You can pick it up as a txt as it is too big to post here.

This solution works really well, except when I try to search on multiple values. When I separate the values with a semicolon, it will only display the last value, unless the text in the first value is the last word in the text string. For example if I enter search values: "rate;preventive" only the Preventive line item will display. However, if I search on: "rate review;preventive", then I'll get both line items. Do I need to modify the code to ensure that I get all results or is this just a limitation of the search. Please help.

Firstly, great work Praveen! I can't thank you enough for this solution. However, multi-value searches seem to be problematic for me. Searching for val1 and val2 using the code above gives the search query *val1;val2* which is incorrect. It returns only search results for val2 or other quirky results. Also, I would rather have an AND keyword search rather than an OR - both val1 and val2 should be present in each search result, even if they are wildcards. I believe the search query should be *val1*+*val2* (correct me if I'm wrong) as described in this code below:

Nice article.I have a similar issue. I have a web part page with 2 list web parts. So I am unable to use the •http://mosssite/pages/listviewcustomwildcardsearch.aspx?FilterName=Title&FilterMultiValue=*prav*