SearchPaneSuggestionsRequest class
Stores suggestions and information about the request for suggestions.
Syntax
var searchPaneSuggestionsRequest = searchPaneSuggestionsRequestedEventArgs.request;
Attributes
- MarshalingBehaviorAttribute(Agile)
- VersionAttribute(NTDDI_WIN8)
Members
The SearchPaneSuggestionsRequest class has these types of members:
Methods
The SearchPaneSuggestionsRequest class has these methods. With C#, Visual Basic, and C++, it also inherits methods from the Object class.
| Method | Description |
|---|---|
| GetDeferral | Retrieves an object that lets an app respond to a request for suggestions asynchronously. |
Properties
The SearchPaneSuggestionsRequest class has these properties.
| Property | Access type | Description |
|---|---|---|
| Read-only | Indicates whether the request for suggestions to display is canceled. | |
| Read-only | The suggestions to display in the search pane for the current query. Apps provide suggestions to display by appending them to this searchSuggestionCollection object. |
Remarks
If your app provides its own suggestions to display in the search pane, use the searchPaneSuggestionsRequest.searchSuggestionCollection property to add your app's suggestions to the collection of suggestions to display.
The search pane can display 5 suggestions, at most. Additionally, each separator you use takes the place of a suggestion and lowers the number of suggestions that you can display.
Examples
The Search contract sample demonstrates how to respond to a suggestionsrequested event, including how to access the searchPaneSuggestionsRequest.
Windows.ApplicationModel.Search.SearchPane.getForCurrentView().onsuggestionsrequested = function (eventObject) { var queryText = eventObject.queryText, language = eventObject.language, suggestionRequest = eventObject.request; // The deferral object is used to supply suggestions asynchronously for example when fetching suggestions from a web service. // Indicate that we'll do this asynchronously: var deferral = suggestionRequest.getDeferral(); // Use the web service Uri entered in the urlInput that supports this standard in order to see suggestions come from the web service. // See http://msdn.microsoft.com/en-us/library/cc848863(v=vs.85).aspx for details on XML Search Suggestions format. // And replace "{searchTerms}" with the query string, which should be encoded into the URI. var suggestionUri = document.getElementById("urlInput").innerText.replace("{searchTerms}", encodeURIComponent(queryText)); // Cancel the previous suggestion request if it is not finished. if (xhrRequest && xhrRequest.cancel) { xhrRequest.cancel(); } // Create request to obtain suggestions from service and supply them to the Search Pane. xhrRequest = WinJS.xhr({ url: suggestionUri }); xhrRequest.done( function (request) { if (request.responseXML) { generateSuggestions(request.responseXML, suggestionRequest.searchSuggestionCollection, queryText); } deferral.complete(); // Indicate we're done supplying suggestions. }, function (error) { WinJS.log && WinJS.log("Error retrieving suggestions for query: " + queryText, "sample", "status"); // Call complete on the deferral when there is an error. deferral.complete(); }); };
Requirements
|
Minimum supported client | Windows 8 [Windows Store apps only] |
|---|---|
|
Minimum supported server | Windows Server 2012 [Windows Store apps only] |
|
Namespace |
|
|
Metadata |
|
See also
- Reference
- Search contract sample
- SearchPane.SuggestionsRequested event
- SearchPaneSuggestionsRequestedEventArgs class
- SearchPaneSuggestionsRequestedEventArgs.Request property
Build date: 12/4/2012
