-
Notifications
You must be signed in to change notification settings - Fork 330
docs(grid): add grid customs doc and demo #3690
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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() | ||
| }) | ||
| 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> |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -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="true"</code> on the <code>grid</code> tag to adjust the column width, and configure <code>resizable="{storage: true}"</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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix demoId typo and incorrect en-US description
{
- 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="true"</code> on the <code>grid</code> tag to adjust the column width, and configure <code>resizable="{storage: true}"</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
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||
| demoId: 'custom-column-simple', | ||||||||||||||||||||||||||||||||||||||||||||||
| name: { 'zh-CN': '简化版列设置', 'en-US': 'Manually Reset Columns' }, | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
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
📝 Committable suggestion
🤖 Prompt for AI Agents