constcc=DataStudioApp.createCommunityConnector();constconfig=cc.getConfig();constoption1=config.newOptionBuilder().setLabel('option label').setValue('option_value');constoption2=config.newOptionBuilder().setLabel('second option label').setValue('option_value_2');constinfo1=config.newSelectSingle().setId('api_endpoint').setName('Data Type').setHelpText('Select the data type you\'re interested in.').addOption(option1).addOption(option2);
Définit le libellé de ce générateur d'options. Les libellés sont le texte que l'utilisateur voit lorsqu'il sélectionne une ou plusieurs options dans le menu déroulant.
Définit la valeur de ce générateur d'options. Les valeurs sont transmises au code lorsqu'un utilisateur sélectionne une ou plusieurs options dans le menu déroulant.
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/07/26 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Il n'y a pas l'information dont j'ai besoin","missingTheInformationINeed","thumb-down"],["Trop compliqué/Trop d'étapes","tooComplicatedTooManySteps","thumb-down"],["Obsolète","outOfDate","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Mauvais exemple/Erreur de code","samplesCodeIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 2025/07/26 (UTC)."],[[["\u003cp\u003e\u003ccode\u003eOptionBuilder\u003c/code\u003e facilitates the creation of options for \u003ccode\u003eSelectSingle\u003c/code\u003e and \u003ccode\u003eSelectMultiple\u003c/code\u003e elements in Data Studio.\u003c/p\u003e\n"],["\u003cp\u003eIt provides methods like \u003ccode\u003esetLabel\u003c/code\u003e and \u003ccode\u003esetValue\u003c/code\u003e to define the display text and underlying value of each option.\u003c/p\u003e\n"],["\u003cp\u003eThese options are then added to \u003ccode\u003eSelectSingle\u003c/code\u003e or \u003ccode\u003eSelectMultiple\u003c/code\u003e components for user interaction within a Data Studio connector.\u003c/p\u003e\n"],["\u003cp\u003eUsing \u003ccode\u003eOptionBuilder\u003c/code\u003e simplifies the process of creating interactive dropdown menus in your custom connectors.\u003c/p\u003e\n"]]],[],null,["OptionBuilder\n\nA builder for creating options for [SelectSingle](/apps-script/reference/data-studio/select-single)s and [SelectMultiple](/apps-script/reference/data-studio/select-multiple)s.\n\n```javascript\nconst cc = DataStudioApp.createCommunityConnector();\nconst config = cc.getConfig();\n\nconst option1 =\n config.newOptionBuilder().setLabel('option label').setValue('option_value');\n\nconst option2 = config.newOptionBuilder()\n .setLabel('second option label')\n .setValue('option_value_2');\n\nconst info1 = config.newSelectSingle()\n .setId('api_endpoint')\n .setName('Data Type')\n .setHelpText('Select the data type you\\'re interested in.')\n .addOption(option1)\n .addOption(option2);\n``` \n\nMethods\n\n| Method | Return type | Brief description |\n|--------------------------------------|--------------------|----------------------------------------|\n| [setLabel(label)](#setLabel(String)) | [OptionBuilder](#) | Sets the label of this option builder. |\n| [setValue(value)](#setValue(String)) | [OptionBuilder](#) | Sets the value of this option builder. |\n\nDetailed documentation \n\n`set``Label(label)` \nSets the label of this option builder. Labels are the text that the user sees when selecting\none or more options from the dropdown.\n\nParameters\n\n| Name | Type | Description |\n|---------|----------|-------------------|\n| `label` | `String` | The label to set. |\n\nReturn\n\n\n[OptionBuilder](#) --- This builder, for chaining.\n\n*** ** * ** ***\n\n`set``Value(value)` \nSets the value of this option builder. Values are what is passed to the code when a user\nselects one or more options from the dropdown.\n\nParameters\n\n| Name | Type | Description |\n|---------|----------|-------------------|\n| `value` | `String` | The value to set. |\n\nReturn\n\n\n[OptionBuilder](#) --- This builder, for chaining."]]