Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions examples/sites/demos/apis/grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,19 @@ export default {
mode: ['pc', 'mobile-first'],
pcDemo: 'grid-faq#custom-column'
},
{
name: 'customs',
typeAnchorName: 'ICustomConfig',
type: 'ICustomConfig[]',
defaultValue: '',
desc: {
'zh-CN': '表格的初始化个性配置,可以控制表格列是否隐藏,设置列宽。优先级高于grid-column上的配置。',
'en-US':
'Initialize the table personalized configuration to control whether the table columns are hidden and set the column width. It takes precedence over the configuration on grid-column.'
},
mode: ['pc', 'mobile-first'],
pcDemo: 'grid-faq#custom-column'
},
{
name: 'data',
typeAnchorName: 'IRow',
Expand Down Expand Up @@ -4212,6 +4225,19 @@ interface ICellClassNameArgs {
// 单元格所在行的序号
seq: number
$seq: string // 已弃用
}`
},
{
name: 'ICustomConfig',
type: 'type',
code: `
interface ICustomConfig {
// 表格列字段
property: string
// 是否显示
visible?: boolean
// 列宽
width?: number | string
}`
}
]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<template>
<tiny-grid :data="tableData" :resizable="true" :customs="customs">
<template #toolbar>
<tiny-grid-toolbar id="default-customs" :resizable="{ storage: true }" setting></tiny-grid-toolbar>
</template>
<tiny-grid-column field="name" title="名称"></tiny-grid-column>
<tiny-grid-column field="employees" title="员工数"></tiny-grid-column>
<tiny-grid-column field="address" :resizable="false" title="地址"></tiny-grid-column>
<tiny-grid-column field="introduction" title="公司简介" show-overflow></tiny-grid-column>
</tiny-grid>
</template>

<script setup>
import { TinyGrid, TinyGridColumn, TinyGridToolbar } from '@opentiny/vue'
import { ref } from 'vue'

const customs = ref([
{ property: 'name', visible: false },
{ property: 'employees', width: 200 }
])

const tableData = ref([
{
id: '1',
name: 'GFD 科技 YX 公司',
address: '福州',
introduction: '公司技术和研发实力雄厚,是国家 863 项目的参与者,并被政府认定为“高新技术企业”。',
employees: 800
},
{
id: '2',
name: 'WWW 科技 YX 公司',
address: '深圳福田区',
introduction: '公司技术和研发实力雄厚,是国家 863 项目的参与者,并被政府认定为“高新技术企业”。',
employees: 300
},
{
id: '3',
name: 'RFV 有限责任公司',
address: '中山市',
introduction: '公司技术和研发实力雄厚,是国家 863 项目的参与者,并被政府认定为“高新技术企业”。',
employees: 1300
},
{
id: '4',
name: 'TGB 科技 YX 公司',
address: '龙岩',
introduction: '公司技术和研发实力雄厚,是国家 863 项目的参与者,并被政府认定为“高新技术企业”。',
employees: 360
},
{
id: '5',
name: 'YHN 科技 YX 公司',
address: '韶关',
introduction: '公司技术和研发实力雄厚,是国家 863 项目的参与者,并被政府认定为“高新技术企业”。',
employees: 810
},
{
id: '6',
name: 'WSX 科技 YX 公司',
address: '黄冈',
introduction: '公司技术和研发实力雄厚,是国家 863 项目的参与者,并被政府认定为“高新技术企业”。',
employees: 800
}
])
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { test, expect } from '@playwright/test'

test('初始化个性配置', async ({ page }) => {
page.on('pageerror', (exception) => expect(exception).toBeNull())
await page.goto('grid-custom#custom-default-csutoms')
const demo = page.locator('#custom-default-csutoms')
await expect(demo.getByRole('cell', { name: '名称' })).not.toBeVisible()
await expect(page.getByRole('cell', { name: '员工数' })).toBeVisible()
Comment on lines +5 to +8
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Standardize demo id spelling and scope assertions to the demo container

  • Fix “csutoms” → “customs” to avoid a lingering typo in routes/anchors.
  • Scope the second assertion to the demo to prevent cross-demo interference.
-  await page.goto('grid-custom#custom-default-csutoms')
-  const demo = page.locator('#custom-default-csutoms')
+  await page.goto('grid-custom#custom-default-customs')
+  const demo = page.locator('#custom-default-customs')
   await expect(demo.getByRole('cell', { name: '名称' })).not.toBeVisible()
-  await expect(page.getByRole('cell', { name: '员工数' })).toBeVisible()
+  await expect(demo.getByRole('cell', { name: '员工数' })).toBeVisible()
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
await page.goto('grid-custom#custom-default-csutoms')
const demo = page.locator('#custom-default-csutoms')
await expect(demo.getByRole('cell', { name: '名称' })).not.toBeVisible()
await expect(page.getByRole('cell', { name: '员工数' })).toBeVisible()
await page.goto('grid-custom#custom-default-customs')
const demo = page.locator('#custom-default-customs')
await expect(demo.getByRole('cell', { name: '名称' })).not.toBeVisible()
await expect(demo.getByRole('cell', { name: '员工数' })).toBeVisible()
🤖 Prompt for AI Agents
In examples/sites/demos/pc/app/grid/custom/default-customs.spec.ts around lines
5 to 8, fix the typo in the route/anchor and demo id from "csutoms" to "customs"
(both in page.goto and the locator selector) and scope the second assertion to
the demo container by changing page.getByRole(...) to demo.getByRole(...) so
both assertions target the same demo element.

})
75 changes: 75 additions & 0 deletions examples/sites/demos/pc/app/grid/custom/default-customs.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<template>
<tiny-grid :data="tableData" :resizable="true" :customs="customs">
<template #toolbar>
<tiny-grid-toolbar id="default-customs" :resizable="{ storage: true }" setting></tiny-grid-toolbar>
</template>
<tiny-grid-column field="name" title="名称"></tiny-grid-column>
<tiny-grid-column field="employees" title="员工数"></tiny-grid-column>
<tiny-grid-column field="address" :resizable="false" title="地址"></tiny-grid-column>
<tiny-grid-column field="introduction" title="公司简介" show-overflow></tiny-grid-column>
</tiny-grid>
</template>

<script>
import { TinyGrid, TinyGridColumn, TinyGridToolbar } from '@opentiny/vue'

export default {
components: {
TinyGrid,
TinyGridColumn,
TinyGridToolbar
},
data() {
return {
customs: [
{ property: 'name', visible: false },
{ property: 'employees', width: 200 }
],
tableData: [
{
id: '1',
name: 'GFD 科技 YX 公司',
address: '福州',
introduction: '公司技术和研发实力雄厚,是国家 863 项目的参与者,并被政府认定为“高新技术企业”。',
employees: 800
},
{
id: '2',
name: 'WWW 科技 YX 公司',
address: '深圳福田区',
introduction: '公司技术和研发实力雄厚,是国家 863 项目的参与者,并被政府认定为“高新技术企业”。',
employees: 300
},
{
id: '3',
name: 'RFV 有限责任公司',
address: '中山市',
introduction: '公司技术和研发实力雄厚,是国家 863 项目的参与者,并被政府认定为“高新技术企业”。',
employees: 1300
},
{
id: '4',
name: 'TGB 科技 YX 公司',
address: '龙岩',
introduction: '公司技术和研发实力雄厚,是国家 863 项目的参与者,并被政府认定为“高新技术企业”。',
employees: 360
},
{
id: '5',
name: 'YHN 科技 YX 公司',
address: '韶关',
introduction: '公司技术和研发实力雄厚,是国家 863 项目的参与者,并被政府认定为“高新技术企业”。',
employees: 810
},
{
id: '6',
name: 'WSX 科技 YX 公司',
address: '黄冈',
introduction: '公司技术和研发实力雄厚,是国家 863 项目的参与者,并被政府认定为“高新技术企业”。',
employees: 800
}
]
}
}
}
</script>
11 changes: 11 additions & 0 deletions examples/sites/demos/pc/app/grid/webdoc/grid-custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@ export default {
},
codeFiles: ['custom/column-width.vue']
},
{
demoId: 'custom-default-csutoms',
name: { 'zh-CN': '初始化个性配置', 'en-US': 'Initialize personal configuration' },
desc: {
'zh-CN':
'<p>在 <code>grid</code> 标签上配置 <code>customs</code> 可以设置表格的初始化个性配置,可以控制表格列的隐藏,列宽等。</p>\n',
'en-US':
'<p>Configure <code>resizable=&quot;true&quot;</code> on the <code>grid</code> tag to adjust the column width, and configure <code>resizable=&quot;{storage: true}&quot;</code> on the <code>toolbar</code> tag to save the column width in <code>localStorage</code> on the local host. The column width of the table on the refreshed page is displayed based on the column width after being dragged.</p>\n'
},
codeFiles: ['custom/default-customs.vue']
},
Comment on lines +16 to +26
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix demoId typo and incorrect en-US description

  • Correct “csutoms” → “customs”.
  • Replace en-US text (it currently describes resizable/localStorage) with “customs” usage to match the demo.
     {
-      demoId: 'custom-default-csutoms',
+      demoId: 'custom-default-customs',
       name: { 'zh-CN': '初始化个性配置', 'en-US': 'Initialize personal configuration' },
       desc: {
         'zh-CN':
           '<p>在 <code>grid</code> 标签上配置 <code>customs</code> 可以设置表格的初始化个性配置,可以控制表格列的隐藏,列宽等。</p>\n',
         'en-US':
-          '<p>Configure <code>resizable=&quot;true&quot;</code> on the <code>grid</code> tag to adjust the column width, and configure <code>resizable=&quot;{storage: true}&quot;</code> on the <code>toolbar</code> tag to save the column width in <code>localStorage</code> on the local host. The column width of the table on the refreshed page is displayed based on the column width after being dragged.</p>\n'
+          '<p>Configure <code>customs</code> on the <code>grid</code> to set initial per‑column visibility and width. It takes precedence over settings on <code>grid-column</code>.</p>\n'
       },
       codeFiles: ['custom/default-customs.vue']
     },
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
{
demoId: 'custom-default-csutoms',
name: { 'zh-CN': '初始化个性配置', 'en-US': 'Initialize personal configuration' },
desc: {
'zh-CN':
'<p>在 <code>grid</code> 标签上配置 <code>customs</code> 可以设置表格的初始化个性配置,可以控制表格列的隐藏,列宽等。</p>\n',
'en-US':
'<p>Configure <code>resizable=&quot;true&quot;</code> on the <code>grid</code> tag to adjust the column width, and configure <code>resizable=&quot;{storage: true}&quot;</code> on the <code>toolbar</code> tag to save the column width in <code>localStorage</code> on the local host. The column width of the table on the refreshed page is displayed based on the column width after being dragged.</p>\n'
},
codeFiles: ['custom/default-customs.vue']
},
{
demoId: 'custom-default-customs',
name: { 'zh-CN': '初始化个性配置', 'en-US': 'Initialize personal configuration' },
desc: {
'zh-CN':
'<p>在 <code>grid</code> 标签上配置 <code>customs</code> 可以设置表格的初始化个性配置,可以控制表格列的隐藏,列宽等。</p>\n',
'en-US':
'<p>Configure <code>customs</code> on the <code>grid</code> to set initial per-column visibility and width. It takes precedence over settings on <code>grid-column</code>.</p>\n'
},
codeFiles: ['custom/default-customs.vue']
},
🤖 Prompt for AI Agents
In examples/sites/demos/pc/app/grid/webdoc/grid-custom.js around lines 16 to 26,
fix the demoId typo and swap the incorrect en-US description: change demoId from
'custom-default-csutoms' to 'custom-default-customs' and replace the current
en-US desc (which mistakenly documents resizable/localStorage) with a concise
description of the demo's actual "customs" usage — e.g., explain that
configuring the grid's customs allows initializing column visibility, order, and
widths (persisted if applicable) and that this demo shows how to apply those
initial personal configurations; keep the zh-CN desc unchanged.

{
demoId: 'custom-column-simple',
name: { 'zh-CN': '简化版列设置', 'en-US': 'Manually Reset Columns' },
Expand Down
4 changes: 2 additions & 2 deletions examples/sites/demos/pc/app/grid/webdoc/grid-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default {
name: { 'zh-CN': '内置编辑器', 'en-US': 'Grid-editor-built-in editor' },
desc: {
'zh-CN': `
<p>通过在 <code>grid</code> 标签上配置 <code>edit-config</code>。在 <code>grid-column</code> 列配置 <code>editor</code> 对象, <code>component</code> 渲染内置编辑组件, <code>events</code> 配置组件事件。</p>
<p>通过在 <code>grid</code> 标签上配置 <code>edit-config</code>。在 <code>grid-column</code> 列配置 <code>editor</code> 对象, <code>component</code> 渲染内置编辑组件,<code>attrs</code>配置组件的属性, <code>events</code> 配置组件事件。</p>
<div class="tip custom-block">
<p class="custom-block-title">特别说明:</p>
<p>内置编辑器只支持 <code>Input</code> 和 <code>Select</code> 组件且均为浏览器原生组件并非 TinyVue 组件,需要使用其他组件可参考自定义编辑器。</p>
Expand All @@ -23,7 +23,7 @@ export default {
name: { 'zh-CN': '自定义编辑器', 'en-US': 'Introducing the TINY component as the editor' },
desc: {
'zh-CN': `
<p> <code>grid</code> 标签上配置 <code>edit-config</code>。\n在 <code>grid-column</code> 列配置 <code>editor</code> 对象, <code>component</code> 渲染自定义编辑组件或者 TinyVue 提供的组件。</p>
<p> <code>grid</code> 标签上配置 <code>edit-config</code>。\n在 <code>grid-column</code> 列配置 <code>editor</code> 对象, <code>component</code> 渲染自定义编辑组件或者 TinyVue 提供的组件。<code>attrs</code>配置组件的属性, <code>events</code> 配置组件事件。</p>
`,
'en-US':
'<p>Introduces the TinyVue <code>Select</code> component through <code>attribute configuration</code>. </p>\n'
Expand Down
Loading