0
votes

I am a Sharepoint novice, please be gentle :-)

I have a Sharepoint 2010 A-Z list with several columns, the important one for this question being a URL column with about 600 hyperlinks. Each of the hyperlinks has a meaningful description displaying, rather than the URL address itself.

On one of my site pages I have an A-Z list view web part connected to that list. I have set it up to only display 30 entries from the list at a time.

What I need to do is provide users with a way to search through the entire 600 URLs to find what they are looking for. For example, if they typed "Onboarding Documents" in the search box, the results should return any URL that has "onboarding" in the description, i.e. the search should be case insensitive.

I found some code that I added into an HTML form web part on a 'search page' that creates a search box and should return a list of search results on the same page, but unfortunately it's only working on single keywords. If I type in "onboarding" it works. If I type "onboarding documents" it doesn't return anything.

At first the search was looking at the URL column and wasn't returning anything under any search terms.

I then tried creating an additional "NotesTest" column in the A-Z list that is a 'single line of text' type column which contains text versions of the hyperlink descriptions. I then tweaked the code to point the search at the NotesTest column instead. This gives returns on single word search terms, but nothing with more than one word.

The code I have in the html form web part is as follows:

function RedirectUrl() {
	var tb = document.getElementById("tbSearch").value;
	var cs = document.getElementById("sfield").value;
	var url = "";

	if (tb != "") {
		if (cs == "NotesTest") {
			url = "FilterField1=" + cs + "&FilterValue1=" + tb;
			window.location.href = "Test-3-SV.aspx?" + url;
		} else {
			url = "FilterName=" + cs + "&FilterMultiValue=*" + tb + "*";
			window.location.href = "Test-3-SV.aspx?" + url;
		}
	} else {
		return false;
	}
}

function ClearUrl() {
	window.location.href = "Test-3-SV.aspx?";
}
Search Field: <select id="sfield"> <option value="URL">URL</option> </select>
Search text: <input id="tbSearch" type="text"/>
<input id="btnSearch" onclick="return RedirectUrl();" type="button" value="Search"/>
<input id="btnClear" onclick="return ClearUrl();" type="button" value="Clear"/>

Here's a sample of entries in the URL column:

  • "Adding a Product"
  • "Adding a Prospect"
  • "Adding a Temporary Overdraft"
  • "Adding an Overdraft"
  • "Adding Other Income"
  • "Adding relaionship training"

What I'd expect to see if I searched on "adding" is all 6 links returned. If I searched on "adding a" I'd expect to see the first three links returned. And if I searched on "adding training" I'd expect to see just the 6th link returned.

Currently if I search on "adding" all 6 links are being returned. But if I add any additional words and spaces into the search box I just get a message

"There are no items to show in this view of the "A-Z" list. To add a new item, click "New".".

1
Hi, welcome to StackOverflow! This question is looking like it's on the track to being quality, but could use a little work. Please start by reviewing how do I ask a good question?. Specifically how to write a minimal reproducible example. Right now it's a little hard to reproduce the example you've given since it involves a lot of ASPX code that we can't see. If this is specific to SharePoint (which I am not at all familiar with) you should add the SharePoint tag.Sandy Gifford

1 Answers

0
votes

Hi I'm not sure if I pictured this correctly however as I understand it.

You have some sort of list web part and some hard coded input type text.

If I were you instead of:

<input id="tbSearch" type="text"/>

I would have filter web part of type text search. Then I would send the parameters of the filter web part to the list web part by means of connection.

The select is also unnecesary as it is another type of filter web part call choice filter.

Although a bit old watch Choice Web Part Video it should also help for the text web filter since its similar.