selettore di classi
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
PickerBuilder
viene utilizzato per creare oggetti Picker
. Salvo diversa indicazione, il tipo di ritorno dei metodi riportati di seguito è di tipo PickerBuilder
, il che consente di concatenare una chiamata dopo l'altra.
Esempi
Crea un Picker
di base utilizzando il pattern di builder.
const picker = new google.pickerPickerBuilder()
.setOAuthToken('TOKEN_FOR_USER')
.setAppId('1234567890') // Cloud Project number
.addView(google.picker.ViewId.DOCS)
.setCallback((data) => {
console.log(data);
})
.build();
Firma
export class PickerBuilder
Dettagli
Metodi
Nome |
Descrizione |
addView(viewOrViewId) |
Aggiungi una visualizzazione al riquadro di navigazione. |
addViewGroup(viewGroup) |
Aggiungi un ViewGroup al riquadro di navigazione di primo livello. |
build() |
Costruisci l'oggetto Picker. |
disableFeature(feature) |
Disattivare una funzionalità del selettore. |
enableFeature(feature) |
Attivare una funzionalità di selettore. |
getRelayUrl() |
Recupera l'URL di inoltro, utilizzato per gadgets.rpc. |
getTitle() |
Recupera il titolo della finestra di dialogo. |
hideTitleBar() |
Disattiva la visualizzazione della barra del titolo. Per riattivarlo, chiama setTitle con un titolo non vuoto o undefined . |
isFeatureEnabled(feature) |
Controlla se è attivato un selettore Feature . |
setAppId(appId) |
Imposta l'ID dell'applicazione che deve accedere ai file dell'utente tramite Drive API . |
setCallback(method) |
Imposta il metodo di callback. Questo metodo viene chiamato quando l'utente seleziona gli articoli o annulla. Il metodo di callback riceve un singolo oggetto di callback. La struttura dell'oggetto callback è descritta nella guida JSON. |
setDeveloperKey(key) |
Imposta la chiave API del browser ottenuta dalla Google Developers Console. Per informazioni dettagliate su come ottenere la chiave API del browser, consulta la Guida per gli sviluppatori. |
setDocument(document) |
Imposta il documento. |
setLocale(locale) |
Imposta le impostazioni internazionali per il selettore. Le impostazioni internazionali sono un codice lingua ISO 639. Se la lingua non è supportata, viene utilizzata la lingua inglese (Stati Uniti). |
setMaxItems(max) |
Imposta il numero massimo di elementi che un utente può scegliere. |
setOAuthToken(token) |
Imposta un token OAuth da utilizzare per autenticare l'utente corrente. |
setOrigin(origin) |
Imposta l'origine della finestra di dialogo del selettore. L'origine deve essere impostata su window.location.protocol + "//" + window.location.host della pagina principale, se l'applicazione è in esecuzione in un iframe. |
setRelayUrl(url) |
Imposta l'URL di inoltro, utilizzato per keys.rpc. |
setSelectableMimeTypes(type) |
Imposta l'elenco dei tipi MIME che saranno selezionabili. Utilizza le virgole per separare i tipi MIME se ne è richiesto più di uno. Se non imposti i tipi MIME, nella visualizzazione vengono visualizzati i file di tutti i tipi MIME. |
setSize(width, height) |
Imposta le dimensioni preferite della finestra di dialogo. La finestra di dialogo verrà centrata automaticamente. Ha una dimensione minima di (566.350) e una dimensione massima di (1051.650). |
setTitle(title) |
Imposta il titolo della finestra di dialogo. |
toUri() |
Restituisce l'URI generato da questo generatore. |
Salvo quando diversamente specificato, i contenuti di questa pagina sono concessi in base alla licenza Creative Commons Attribution 4.0, mentre gli esempi di codice sono concessi in base alla licenza Apache 2.0. Per ulteriori dettagli, consulta le norme del sito di Google Developers. Java è un marchio registrato di Oracle e/o delle sue consociate.
Ultimo aggiornamento 2025-07-25 UTC.
[null,null,["Ultimo aggiornamento 2025-07-25 UTC."],[],[],null,["# Class PickerBuilder\n\n`PickerBuilder` is used to create `Picker` objects. Except where noted\notherwise, the return type of methods below is of type `PickerBuilder`, allowing\nyou to chain one call after another.\n\nExamples\n--------\n\nBuild a basic `Picker` using the builder pattern. \n\n const picker = new google.pickerPickerBuilder()\n .setOAuthToken('TOKEN_FOR_USER')\n .setAppId('1234567890') // Cloud Project number\n .addView(google.picker.ViewId.DOCS)\n .setCallback((data) =\u003e {\n console.log(data);\n })\n .build();\n\nSignature\n---------\n\n export class PickerBuilder\n\nDetails\n-------\n\n| Final | No |\n|-------|----|\n\nMethods\n-------\n\n| Name | Description |\n|---------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [`addView(viewOrViewId)`](./picker.pickerbuilder.addview) | Add a view to the navigation pane. |\n| [`addViewGroup(viewGroup)`](./picker.pickerbuilder.addviewgroup) | Add a ViewGroup to the top-level navigation pane. |\n| [`build()`](./picker.pickerbuilder.build) | Construct the Picker object. |\n| [`disableFeature(feature)`](./picker.pickerbuilder.disablefeature) | Disable a picker feature. |\n| [`enableFeature(feature)`](./picker.pickerbuilder.enablefeature) | Enable a picker feature. |\n| [`getRelayUrl()`](./picker.pickerbuilder.getrelayurl) | Get the relay URL, used for gadgets.rpc. |\n| [`getTitle()`](./picker.pickerbuilder.gettitle) | Get the dialog title. |\n| [`hideTitleBar()`](./picker.pickerbuilder.hidetitlebar) | Disable the title bar from being shown. To re-enable, call `setTitle` with a non-empty title or `undefined`. |\n| [`isFeatureEnabled(feature)`](./picker.pickerbuilder.isfeatureenabled) | Check if a picker `Feature` is enabled. |\n| [`setAppId(appId)`](./picker.pickerbuilder.setappid) | Sets the Id of the application needing to access the user's files via the [`Drive API`](/workspace/drive/api). |\n| [`setCallback(method)`](./picker.pickerbuilder.setcallback) | 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](/workspace/drive/picker/reference/results). |\n| [`setDeveloperKey(key)`](./picker.pickerbuilder.setdeveloperkey) | 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. |\n| [`setDocument(document)`](./picker.pickerbuilder.setdocument) | Set the document. |\n| [`setLocale(locale)`](./picker.pickerbuilder.setlocale) | Set the locale for the picker. The locale is an ISO 639 language code. If the language is not supported, en-US is used. |\n| [`setMaxItems(max)`](./picker.pickerbuilder.setmaxitems) | Sets the maximum number of items a user can pick. |\n| [`setOAuthToken(token)`](./picker.pickerbuilder.setoauthtoken) | Sets an OAuth token to use for authenticating the current user. |\n| [`setOrigin(origin)`](./picker.pickerbuilder.setorigin) | 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. |\n| [`setRelayUrl(url)`](./picker.pickerbuilder.setrelayurl) | Set the relay URL, used for gadgets.rpc. |\n| [`setSelectableMimeTypes(type)`](./picker.pickerbuilder.setselectablemimetypes) | 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. |\n| [`setSize(width, height)`](./picker.pickerbuilder.setsize) | 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). |\n| [`setTitle(title)`](./picker.pickerbuilder.settitle) | Set the dialog title. |\n| [`toUri()`](./picker.pickerbuilder.touri) | Returns the URI generated by this builder. |"]]