Constructor

Builder

new Builder()

Example

// Builds a results container.
function onload() {
  gapi.client.init({
    'apiKey': '<your api key>',
    'clientId': '<your client id>',
    // Add additional scopes if needed
    'scope': 'https://www.googleapis.com/auth/cloud_search.query',
    'hosted_domain': '<your G Suite domain>',
  });

  const resultscontainer =
      new gapi.cloudsearch.widget.resultscontainer.Builder()
        .setSearchResultsContainerElement(document.getElementById('search_result'))
        .build();

  const searchBox = new gapi.cloudsearch.widget.searchbox.Builder()
    .setInput(document.getElementById('input'))
    .setAnchor(document.getElementById('input').parentElement)
    .setResultsContainer(resultscontainer);
    .build();
}
gapi.load('client:cloudsearch-widget', onload);

Methods

build

build() returns ResultsContainer

Builds the results container.

Returns

non-null ResultsContainer 

setAdapter

setAdapter(adapter) returns Builder

Optional. Sets the adapter to customize the user experience.

Parameter

adapter

ResultsContainerAdapter

Value must not be null.

Returns

non-null Builder this

setFacetResultsContainerElement

setFacetResultsContainerElement(facetResultsContainerElement) returns Builder

Sets the container Element for facet results. Must be a valid Element that can contain child nodes.

Parameter

facetResultsContainerElement

Element

Value must not be null.

Returns

non-null Builder this

setIncludePagination

setIncludePagination(includePagination) returns Builder

Optional. Default true. Includes a default pagination UI in the results container, if set to true.

Parameter

includePagination

boolean

Returns

non-null Builder this

setResultsContainer

setResultsContainer(resultsContainer) returns Builder

Required. Sets the Element of the container. Must be a valid Element that can contain child nodes.

Parameter

resultsContainer

Element

Value must not be null.

Deprecated
Returns

non-null Builder this

setSearchApplicationId

setSearchApplicationId(searchApplicationId) returns Builder

Optional. Sets the search application ID to use for requests. Must be prefixed with 'searchapplications/'.

Parameter

searchApplicationId

string

Returns

non-null Builder this

setSearchResultsContainerElement

setSearchResultsContainerElement(searchResultsContainerElement) returns Builder

Required. Sets the Element of the container. Must be a valid Element that can contain child nodes.

Parameter

searchResultsContainerElement

Element

Value must not be null.

Returns

non-null Builder this