1,804 articles and 15,293 comments as of Monday, December 27th, 2010

Friday, October 30, 2009

jQuery – List and Document Library Search Solution in SharePoint

Peter AllenGuest Author: Peter Allen
BitsOfSharePoint

Search has not been easy with SharePoint 2007 and especially with WSS 3.0.  For example many times I just want to search list or document library.  What I want is ability to see what items match what I’m looking for specifically with the list that is showing right now.  I would like to search, not have to refresh the page or go to another location to do the search.

I have been developing another site with SharePoint WSS 3.0 and needed to have such a solution.  The site www.mobilesitezone.net (this is designed for smartphones) is a very customized SharePoint site. I then adapted the search created for it to work with any SharePoint List or Document Library.

What was created was a jQuery search solution that only looked at the list on the page and filtered results based on the search criteria.  It will search all the fields that are shown on the site and then show you the rows that have any matches.

Here is an example where there is a large list of over 400 items and then a search is made for "google" which then displays just the results.

List

jQuery List and Document

Results

jQuery List and Document

I have put together an example page where you can test this out and get the WebPart or Code for CEWP to add this to your site.

Click here to get the solution

Hope you enjoy,

Peter

Peter AllenGuest Author: Peter Allen
BitsOfSharePoint

Peter Allen is a SharePoint enthusiast and evangelist having deployed solutions in Healthcare, financial, and engineering firms.  He has worked in the technology field for 15 years creating solutions both internally and externally for clients. He has worked at start-ups, mid and larger corporations and has consulted.  He currently hosts a site http://www.bitsofsharepoint.com where he blogs about solutions to extend the features of SharePoint.

View all entries in this series: PeterAllen - jQuery List and Document Library»
Entries in this series:
  1. jQuery - List and Document Library Search Solution in SharePoint
  2. jQuery – List and Document Library Filter Version 2.0 - Part 2
 

Please Join the Discussion

22 Responses to “jQuery – List and Document Library Search Solution in SharePoint”
  1. Shalin Parmar says:

    Nice article! Really simple and effective solution.

  2. Good job Peter :)
    Thanks for Sharing

  3. PatrikTX says:

    Awesome Peter! Great presentation and THANK YOU for the webpart!

  4. TG says:

    Pretty slick Peter though a bit slow on a list of 900+ items and 7 fields in the view. A progress bar or spinning icon could help.

  5. Peter Allen says:

    I agree. I have been looking at ways to speed this up. I hope to have a second version out soon that will address this. MS did not make the tables simple with regards to list in SharePoint. There are a lot tables within tables and this has made it challenge.

    Thank all for the feedback.

  6. Peter Allen says:

    TG, I have an updated version that I think works faster. If you would like to test, please email me. You can get my contact info at my site, http://www.bitsofsharepoint.com.

    Thanks,

    Peter

  7. Eric says:

    Very slick, but is there a way to expand the scope of the search beyond the current page of items? I have a view that batches items by 100’s and would like to see results in the filter from the entire list, not just the items on the current page.

    It’s a great solution regardless but I have some very large lists that would preclude the use of the solution as it exists now.

  8. Tony says:

    Yet again something that should have been an OOTB feature is plugged by a 3rd party genius ;)

    Is there anyway to get this to work with dataview webparts created in Sharepoint designer?

  9. Peter Allen says:

    Eric,

    I understand your dilemma. Unfortunately this solution will not work for your scenario.

    But I am working on a solution that may help you. It will be a different way to filter/search your list. This will be more involved solution since we will be looking at going beyond just filtering the viewable items in a list and this will require use of SharePoint Designer.

    I hope to have this out shortly.

  10. Peter Allen says:

    Tony,

    Ubet. Since you have created a Data View Web Part (DVWP) there is a missing class that can be added to fix this. If you look at my code I am looking for tables that have a class called “ms-listviewtable”. OOTB Web Parts have this class added by default. DVWP when created do not get this class and so my solution does not find the table.

    Easy fix: Add a class to the table element. If you look at the code for your DVWP (I like the split view in SharePoint Designer), look for the TH elements you will then see above them the table element. It will look something like this:

    Notice there is no class listed at all. You will add class=”ms-listviewtable” to the table element. It should look like this:

    That should fix it.
    Hope that helps

  11. Tony says:

    Bingo! Thanks that works a treat. :)

  12. Harsha Harish says:

    Great webpart.. Definitely useful…

    I did notice that if the items are groups and collapsed.. the filter does not work.. the list items need to be expanded before it can filter it…

    Is this by design or something stupid on my side.?

  13. Peter Allen says:

    Harsha,

    There is nothing that you have done wrong. This is a feature that I hope to add in to later versions. For now the grouping needs to be expanded for it to work.

  14. Andrew says:

    bitsofsharepoint.com is down…does anyone have a mirror to the script?

  15. Peter Allen says:

    Sorry all for the site being down. My provider has fixed the problem and we are back in business, YEAH!

  16. michael says:

    cool solution!

  17. Mike says:

    Hello,

    is there any chance to realize tgis on Sharepoint Foundation? Maybe someone done this already. On 2007 this is no Problem for me but since the Designer changes dramaticly i cant get this to work.

    Thanks Mike

  18. Arpit says:

    Hi Peter

    i am using your search webpart
    I configure as you mention . but when i put something on seach box and search it comes with blank page every time, nothing appears on data view web part page which i customize.

    i checked i put right path in location box as well .it opens that page but nothing on it.

Trackbacks

Check out what others are saying about this post...
  1. [...] easy to get to the information needed from the list currently being viewed.  Original article: jQuery – List and Document Library Filtering Solution In the latest version 2.0 the purpose has not changed, but improvements have been [...]

  2. [...] jQuery – List and Document Library Search Solution in SharePoint [...]




Notify me of comments to this article:


Speak and you will be heard.

We check comments hourly.
If you want a pic to show with your comment, go get a gravatar!