Class GetDataResponse
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
GetDataResponse
建構工具,可為指令碼專案建立 getData()
回應。
function getFields() {
//...
}
function getData() {
const cc = DataStudioApp.createCommunityConnector();
return cc.newGetDataResponse()
.setFields(getFields())
.addRow(['3', 'Foobar.com'])
.addRow(['4', 'Foobaz.com'])
.addRows([
['5', 'Fizzbuz.com'],
['6', 'Fizzbaz.com'],
])
.build();
}
內容詳盡的說明文件
setFiltersApplied(filtersApplied)
設定這個建構工具套用篩選器的狀態。如果所有篩選器都已成功套用,請將其設為 true
;如果不是,請設為 false
。
參數
名稱 | 類型 | 說明 |
filtersApplied | Boolean | - 要設定的篩選器套用狀態。 |
回攻員
GetDataResponse
:這個建構工具可用於鏈結。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-07-26 (世界標準時間)。
[null,null,["上次更新時間:2025-07-26 (世界標準時間)。"],[[["\u003cp\u003e\u003ccode\u003eGetDataResponse\u003c/code\u003e helps structure the data your script returns to Data Studio for visualization.\u003c/p\u003e\n"],["\u003cp\u003eIt provides methods like \u003ccode\u003eaddRow\u003c/code\u003e, \u003ccode\u003eaddAllRows\u003c/code\u003e, and \u003ccode\u003esetFields\u003c/code\u003e to define the data structure and content.\u003c/p\u003e\n"],["\u003cp\u003eUse \u003ccode\u003ebuild()\u003c/code\u003e to finalize and send the data to Data Studio in the correct format.\u003c/p\u003e\n"],["\u003cp\u003eYou can signal if Data Studio filters were applied using \u003ccode\u003esetFiltersApplied\u003c/code\u003e.\u003c/p\u003e\n"]]],[],null,["# Class GetDataResponse\n\nGetDataResponse\n\nBuilder to create a `get``Data()` response for your script project.\n\n```javascript\nfunction getFields() {\n //...\n}\n\nfunction getData() {\n const cc = DataStudioApp.createCommunityConnector();\n\n return cc.newGetDataResponse()\n .setFields(getFields())\n .addRow(['3', 'Foobar.com'])\n .addRow(['4', 'Foobaz.com'])\n .addRows([\n ['5', 'Fizzbuz.com'],\n ['6', 'Fizzbaz.com'],\n ])\n .build();\n}\n``` \n\n### Methods\n\n| Method | Return type | Brief description |\n|------------------------------------------------------------------|----------------------|------------------------------------------------------------------------------|\n| [addAllRows(rows)](#addAllRows(String)) | [GetDataResponse](#) | Adds multiple rows of data to this [GetDataResponse](#). |\n| [addRow(row)](#addRow(String)) | [GetDataResponse](#) | Adds a row of data to this [GetDataResponse](#). |\n| [build()](#build()) | `Object` | Validates this object and returns it in the format needed by Data Studio. |\n| [setFields(fields)](#setFields(Fields)) | [GetDataResponse](#) | Sets the [Fields](/apps-script/reference/data-studio/fields) of the builder. |\n| [setFiltersApplied(filtersApplied)](#setFiltersApplied(Boolean)) | [GetDataResponse](#) | Sets the filters applied status for this builder. |\n\nDetailed documentation\n----------------------\n\n### `add``All``Rows(rows)`\n\nAdds multiple rows of data to this [GetDataResponse](#).\n\n#### Parameters\n\n| Name | Type | Description |\n|--------|--------------|--------------------------|\n| `rows` | `String[][]` | The rows of data to set. |\n\n#### Return\n\n\n[GetDataResponse](#) --- This builder, for chaining.\n\n*** ** * ** ***\n\n### `add``Row(row)`\n\nAdds a row of data to this [GetDataResponse](#).\n\n#### Parameters\n\n| Name | Type | Description |\n|-------|------------|-------------------------|\n| `row` | `String[]` | The row of data to set. |\n\n#### Return\n\n\n[GetDataResponse](#) --- This builder, for chaining.\n\n*** ** * ** ***\n\n### `build()`\n\nValidates this object and returns it in the format needed by Data Studio.\n\n#### Return\n\n\n`Object` --- The validated [GetDataResponse](#) object.\n\n*** ** * ** ***\n\n### `set``Fields(fields)`\n\nSets the [Fields](/apps-script/reference/data-studio/fields) of the builder.\n\n#### Parameters\n\n| Name | Type | Description |\n|----------|-----------------------------------------------------|--------------------|\n| `fields` | [Fields](/apps-script/reference/data-studio/fields) | The fields to set. |\n\n#### Return\n\n\n[GetDataResponse](#) --- This builder, for chaining.\n\n*** ** * ** ***\n\n### `set``Filters``Applied(filtersApplied)`\n\nSets the filters applied status for this builder. Set to `true` if all filters were\nsuccessfully applied, `false` otherwise.\n\n#### Parameters\n\n| Name | Type | Description |\n|--------------------|-----------|--------------------------------------|\n| `filters``Applied` | `Boolean` | - The filters applied status to set. |\n\n#### Return\n\n\n[GetDataResponse](#) --- This builder, for chaining."]]