Class Columns
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
คอลัมน์
วิดเจ็ต Columns
จะแสดงได้สูงสุด 2 คอลัมน์ในการ์ดหรือกล่องโต้ตอบ คุณสามารถเพิ่มวิดเจ็ตลงใน Column
แต่ละรายการได้ โดยวิดเจ็ตจะปรากฏตามลำดับที่ระบุ ดูตัวอย่างในแอป Google Chat ได้ที่คอลัมน์
ความสูงของแต่ละคอลัมน์จะกำหนดโดยคอลัมน์ที่สูงกว่า เช่น หากคอลัมน์แรกสูงกว่าคอลัมน์ที่ 2 คอลัมน์ทั้ง 2 คอลัมน์จะมีความสูงเท่ากับคอลัมน์แรก เนื่องจากแต่ละคอลัมน์อาจมีวิดเจ็ตจํานวนต่างกัน คุณจึงไม่สามารถกําหนดแถวหรือจัดแนววิดเจ็ตระหว่างคอลัมน์
คอลัมน์จะแสดงคู่กัน คุณปรับความกว้างของแต่ละคอลัมน์ได้โดยใช้ช่อง HorizontalSizeStyle
หากความกว้างของหน้าจอผู้ใช้แคบเกินไป คอลัมน์ที่ 2 จะตัดไปอยู่ด้านล่างคอลัมน์แรก
- ในเว็บ คอลัมน์ที่ 2 จะตัดขึ้นบรรทัดใหม่หากความกว้างของหน้าจอน้อยกว่าหรือเท่ากับ 480 พิกเซล
- ในอุปกรณ์ iOS คอลัมน์ที่ 2 จะตัดขึ้นบรรทัดใหม่หากความกว้างของหน้าจอน้อยกว่าหรือเท่ากับ 300 pt
- ในอุปกรณ์ Android คอลัมน์ที่ 2 จะตัดขึ้นบรรทัดใหม่หากความกว้างของหน้าจอน้อยกว่าหรือเท่ากับ 320 dp
พร้อมใช้งานสำหรับแอป Google Chat และส่วนเสริมของ Google Workspace UI ของส่วนเสริมที่รองรับคอลัมน์ ได้แก่
- กล่องโต้ตอบที่แสดงเมื่อผู้ใช้เปิดส่วนเสริมจากอีเมลฉบับร่าง
- กล่องโต้ตอบที่แสดงเมื่อผู้ใช้เปิดส่วนเสริมจากเมนูเพิ่มไฟล์แนบในกิจกรรม Google ปฏิทิน
// Build a column that is aligned in the center and fills the space:
const column =
CardService.newColumn()
.setHorizontalSizeStyle(
CardService.HorizontalSizeStyle.FILL_AVAILABLE_SPACE)
.setHorizontalAlignment(CardService.HorizontalAlignment.CENTER)
.setVerticalAlignment(CardService.VerticalAlignment.CENTER);
const columns = CardService.newColumns().addColumn(column).setWrapStyle(
CardService.WrapStyle.WRAP);
เอกสารประกอบโดยละเอียด
addColumn(column)
เพิ่ม Column
ลงในวิดเจ็ตคอลัมน์ คอลัมน์จะแสดงตามลำดับที่เพิ่ม คุณเพิ่มได้สูงสุด 2 คอลัมน์
const columns = CardService.newColumns().addColumn(CardService.newColumn());
พารามิเตอร์
ชื่อ | ประเภท | คำอธิบาย |
column | Column | คอลัมน์ย่อยที่จะเพิ่มลงในวิดเจ็ตคอลัมน์ |
รีเทิร์น
Columns
— ออบเจ็กต์นี้สําหรับการต่อเชื่อม
setWrapStyle(wrapStyle)
กำหนดรูปแบบการตัดของคอลัมน์ ควบคุมวิธีปรับขนาดคอลัมน์ตามความกว้างของหน้าจอ
const columns = CardService.newColumns()
.addColumn(CardService.newColumn())
.setWrapStyle(CardService.WrapStyle.WRAP);
พารามิเตอร์
ชื่อ | ประเภท | คำอธิบาย |
wrapStyle | WrapStyle | รูปแบบการตัดขึ้นบรรทัดใหม่ที่จะตั้งค่าสำหรับคอลัมน์ |
รีเทิร์น
Columns
— ออบเจ็กต์นี้สําหรับการต่อเชื่อม
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-26 UTC
[null,null,["อัปเดตล่าสุด 2025-07-26 UTC"],[[["\u003cp\u003eThe Columns widget allows displaying up to two columns within cards or dialogs, with widgets arranged vertically within each column.\u003c/p\u003e\n"],["\u003cp\u003eColumn height is determined by the taller column, and widgets cannot be aligned across columns or organized into rows.\u003c/p\u003e\n"],["\u003cp\u003eColumns are displayed side-by-side and wrap to a vertical layout on smaller screens based on specified screen width thresholds.\u003c/p\u003e\n"],["\u003cp\u003eCustomization options include adjusting column width and controlling wrapping behavior with \u003ccode\u003eHorizontalSizeStyle\u003c/code\u003e and \u003ccode\u003eWrapStyle\u003c/code\u003e respectively.\u003c/p\u003e\n"],["\u003cp\u003eThis widget is available for Google Chat apps and specific Google Workspace Add-ons, like dialogs in email drafts or Calendar event attachments.\u003c/p\u003e\n"]]],["The Columns widget displays up to two columns in a card or dialog, with widgets added to each column in a specified order. Column height is determined by the taller column, and widths can be customized. If the screen is too narrow, the second column wraps below the first, with specific pixel/point/dp thresholds for web, iOS, and Android devices. Key actions include adding columns using `addColumn()` and controlling resizing with `setWrapStyle()`. These features are available for Google Chat and Workspace add-ons.\n"],null,["# Class Columns\n\nColumns\n\nThe [Columns](#) widget displays up to 2 columns in a card or dialog. You can add widgets to\neach [Column](/apps-script/reference/card-service/column); the widgets appear in the order that they are specified. For an example in\nGoogle Chat apps, see [Columns](https://developers.google.com/workspace/chat/format-structure-card-dialog#display_cards_and_dialogs_in_columns).\n\nThe height of each column is determined by the taller column. For example, if the first column\nis taller than the second column, both columns have the height of the first column. Because each\ncolumn can contain a different number of widgets, you can't define rows or align widgets between\nthe columns.\n\nColumns are displayed side-by-side. You can customize the width of each column using the\n[HorizontalSizeStyle](/apps-script/reference/card-service/horizontal-size-style) field. If the user's screen width is too narrow, the second column\nwraps below the first:\n\n- On web, the second column wraps if the screen width is less than or equal to 480 pixels.\n- On iOS devices, the second column wraps if the screen width is less than or equal to 300 pt.\n- On Android devices, the second column wraps if the screen width is less than or equal to 320 dp.\n\nAvailable for Google Chat apps and Google Workspace add-ons. The add-on UIs that support\ncolumns include:\n\n- The dialog displayed when users open the add-on from an email draft.\n- The dialog displayed when users open the add-on from the **Add attachment** menu in a Google Calendar event. \n\n ```javascript\n // Build a column that is aligned in the center and fills the space:\n const column =\n CardService.newColumn()\n .setHorizontalSizeStyle(\n CardService.HorizontalSizeStyle.FILL_AVAILABLE_SPACE)\n .setHorizontalAlignment(CardService.HorizontalAlignment.CENTER)\n .setVerticalAlignment(CardService.VerticalAlignment.CENTER);\n const columns = CardService.newColumns().addColumn(column).setWrapStyle(\n CardService.WrapStyle.WRAP);\n``` \n\n### Methods\n\n| Method | Return type | Brief description |\n|-----------------------------------------------------|--------------|--------------------------------------------------------------------------------------------|\n| [addColumn(column)](#addColumn(Column)) | [Columns](#) | Adds a [Column](/apps-script/reference/card-service/column) to the Columns widget. |\n| [setWrapStyle(wrapStyle)](#setWrapStyle(WrapStyle)) | [Columns](#) | Sets the wrap style of the columns, controls how the column resizes based on screen width. |\n\nDetailed documentation\n----------------------\n\n### `add``Column(column)`\n\nAdds a [Column](/apps-script/reference/card-service/column) to the Columns widget. Columns are displayed in the order in which\nthey're added. You can add up to two columns.\n\n```javascript\nconst columns = CardService.newColumns().addColumn(CardService.newColumn());\n```\n\n#### Parameters\n\n| Name | Type | Description |\n|----------|------------------------------------------------------|----------------------------------------------|\n| `column` | [Column](/apps-script/reference/card-service/column) | A child column to add to the Columns widget. |\n\n#### Return\n\n\n[Columns](#) --- This object, for chaining.\n\n*** ** * ** ***\n\n### `set``Wrap``Style(wrapStyle)`\n\nSets the wrap style of the columns, controls how the column resizes based on screen width.\n\n```javascript\nconst columns = CardService.newColumns()\n .addColumn(CardService.newColumn())\n .setWrapStyle(CardService.WrapStyle.WRAP);\n```\n\n#### Parameters\n\n| Name | Type | Description |\n|---------------|-------------------------------------------------------------|----------------------------------------|\n| `wrap``Style` | [WrapStyle](/apps-script/reference/card-service/wrap-style) | The wrap style to set for the columns. |\n\n#### Return\n\n\n[Columns](#) --- This object, for chaining."]]