Class: Builder

Constructor

Builder

new Builder()

Example

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

  const resultscontainer &#x3D;
      new gapi.cloudsearch.widget.resultscontainer.Builder()
        .setSearchResultsContainerElement(document.getElementById(&#x27;search_result&#x27;))
        .build();

  const searchBox &#x3D; new gapi.cloudsearch.widget.searchbox.Builder()
    .setInput(document.getElementById(&#x27;input&#x27;))
    .setAnchor(document.getElementById(&#x27;input&#x27;).parentElement)
    .setResultsContainer(resultscontainer);
    .build();
}
gapi.load(&#x27;client:cloudsearch-widget&#x27;, 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