Class PickerBuilder

PickerBuilder is used to create Picker objects. Except where noted otherwise, the return type of methods below is of type PickerBuilder, allowing you to chain one call after another.

Examples

Build a basic Picker using the builder pattern.

const picker = new google.pickerPickerBuilder()
  .setOAuthToken('token_for_user')
  .setAppId('1234567890')
  .addView(google.picker.ViewId.DOCS)
  .setCallback((data) => {
    console.log(data);
  })
  .build();

Signature

export class PickerBuilder

Details

Final No

Methods

Name Description
addView(viewOrViewId) Add a view to the navigation pane.
addViewGroup(viewGroup) Add a ViewGroup to the top-level navigation pane.
build() Construct the Picker object.
disableFeature(feature) Disable a picker feature.
enableFeature(feature) Enable a picker feature.
getRelayUrl() Get the relay URL, used for gadgets.rpc.
getTitle() Get the dialog title.
hideTitleBar() Disable the title bar from being shown. To re-enable, call setTitle with a non-empty title or undefined.
isFeatureEnabled(feature) Check if a picker Feature is enabled.
setAppId(appId) Sets the Id of the application needing to access the user's files via the Drive API.
setCallback(method) Set the callback method. This method is called when the user selects items or cancels. The callback method receives a single callback object. The structure of the callback object is described in the JSON Guide.
setDeveloperKey(key) Sets the Browser API key obtained from Google Developers Console. See the Developer's Guide for details on how to obtain the Browser API key.
setDocument(document) Set the document.
setLocale(locale) ISO 639 language code. If the language is not supported, en-US is used. This method provides an alternative to setting the locale at google.load() time. See the Developer's Guide for a list of supported locales.
setMaxItems(max) Sets the maximum number of items a user can pick.
setOAuthToken(token) Sets an OAuth token to use for authenticating the current user.
setOrigin(origin) Sets the origin of picker dialog. The origin should be set to the window.location.protocol + '//' + window.location.host of the top-most page, if your application is running in an iframe.
setRelayUrl(url) Set the relay URL, used for gadgets.rpc.
setSelectableMimeTypes(type) Set the list of MIME types which will be selectable. Use commas to separate MIME types if more than one is required. If you don't set MIME types, files of all MIME types are displayed in the view.
setSize(width, height) Set the preferred dialog size. The dialog will be auto-centered. It has a minimum size of (566,350) and a maximum size of (1051,650).
setTitle(title) Set the dialog title.
toUri() Returns the URI generated by this builder.