-
Notifications
You must be signed in to change notification settings - Fork 331
feat(grid): [grid] expose getTreeExpandeds function #2996
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
149 changes: 149 additions & 0 deletions
149
examples/sites/demos/pc/app/grid/tree-table/tree-table-tree-grid-expand-composition-api.vue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,149 @@ | ||
| <template> | ||
| <div> | ||
| <tiny-grid | ||
| ref="treeGridRef" | ||
| :data="tableData" | ||
| :tree-config="{ children: 'children' }" | ||
| @toggle-tree-change="handTreeExpand" | ||
| > | ||
| <tiny-grid-column type="index" width="80" tree-node></tiny-grid-column> | ||
| <tiny-grid-column field="name" title="公司名称"></tiny-grid-column> | ||
| <tiny-grid-column field="area" title="区域"></tiny-grid-column> | ||
| <tiny-grid-column field="employees" title="员工数"></tiny-grid-column> | ||
| </tiny-grid> | ||
| </div> | ||
| </template> | ||
|
|
||
| <script setup lang="jsx"> | ||
| import { ref } from 'vue' | ||
| import { TinyGrid, TinyGridColumn, TinyModal } from '@opentiny/vue' | ||
| const tableData = ref([ | ||
| { | ||
| id: '1', | ||
| pid: '0', | ||
| name: 'GFD 科技 YX 公司', | ||
| area: '华东区', | ||
| employees: '800', | ||
| introduction: '公司技术和研发实力雄厚,是国家 863 项目的参与者,并被政府认定为“高新技术企业”。', | ||
| children: [ | ||
| { | ||
| id: '15', | ||
| pid: '1', | ||
| name: 'GFD 科技股份有限子公司', | ||
| area: '华东区', | ||
| employees: '700', | ||
| introduction: '公司技术和研发实力雄厚,是国家 863 项目的参与者,并被政府认定为“高新技术企业”。' | ||
| } | ||
| ] | ||
| }, | ||
| { | ||
| id: '2', | ||
| pid: '0', | ||
| name: 'WWWW 科技 YX 公司', | ||
| area: '华南区', | ||
| employees: '500', | ||
| introduction: '公司技术和研发实力雄厚,是国家 863 项目的参与者,并被政府认定为“高新技术企业”。', | ||
| children: [ | ||
| { | ||
| id: '22', | ||
| pid: '2', | ||
| name: 'WWWW 科技股份有限子公司', | ||
| area: '华南区', | ||
| employees: '720', | ||
| introduction: '公司技术和研发实力雄厚,是国家 863 项目的参与者,并被政府认定为“高新技术企业”。' | ||
| } | ||
| ] | ||
| }, | ||
| { | ||
| id: '4', | ||
| pid: '0', | ||
| name: 'TGBYX 公司', | ||
| area: '华南区', | ||
| employees: '360', | ||
| introduction: '公司技术和研发实力雄厚,是国家 863 项目的参与者,并被政府认定为“高新技术企业”。', | ||
| children: [ | ||
| { | ||
| id: '3', | ||
| pid: '4', | ||
| name: 'RFV 有限责任公司', | ||
| area: '华南区', | ||
| employees: '300', | ||
| introduction: '公司技术和研发实力雄厚,是国家 863 项目的参与者,并被政府认定为“高新技术企业”。' | ||
| }, | ||
| { | ||
| id: '5', | ||
| pid: '4', | ||
| name: 'YHN 科技 YX 公司', | ||
| area: '华南区', | ||
| employees: '810', | ||
| introduction: '公司技术和研发实力雄厚,是国家 863 项目的参与者,并被政府认定为“高新技术企业”。', | ||
| children: [ | ||
| { | ||
| id: '6', | ||
| pid: '5', | ||
| name: 'WSX 科技 YX 公司', | ||
| area: '华南区', | ||
| employees: '800', | ||
| introduction: '公司技术和研发实力雄厚,是国家 863 项目的参与者,并被政府认定为“高新技术企业”。' | ||
| }, | ||
| { | ||
| id: '9', | ||
| pid: '5', | ||
| name: 'UJM 有限责任公司', | ||
| area: '华南区', | ||
| employees: '750', | ||
| introduction: '公司技术和研发实力雄厚,是国家 863 项目的参与者,并被政府认定为“高新技术企业”。' | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| }, | ||
| { | ||
| id: '7', | ||
| pid: '0', | ||
| name: '康康物业 YX 公司', | ||
| area: '华南区', | ||
| employees: '400', | ||
| introduction: '公司技术和研发实力雄厚,是国家 863 项目的参与者,并被政府认定为“高新技术企业”。', | ||
| children: [ | ||
| { | ||
| id: '8', | ||
| pid: '7', | ||
| name: '深圳市福德宝网络技术 YX 公司', | ||
| area: '华南区', | ||
| employees: '540', | ||
| introduction: '公司技术和研发实力雄厚,是国家 863 项目的参与者,并被政府认定为“高新技术企业”。' | ||
| }, | ||
| { | ||
| id: '10', | ||
| pid: '7', | ||
| name: 'IK 有限责任公司', | ||
| area: '华南区', | ||
| employees: '400', | ||
| introduction: '公司技术和研发实力雄厚,是国家 863 项目的参与者,并被政府认定为“高新技术企业”。', | ||
| children: [ | ||
| { | ||
| id: '23', | ||
| pid: '10', | ||
| name: 'IK 有限责任股份 YX 公司', | ||
| area: '华南区', | ||
| employees: '455', | ||
| introduction: '公司技术和研发实力雄厚,是国家 863 项目的参与者,并被政府认定为“高新技术企业”。' | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
| ]) | ||
| const treeGridRef = ref() | ||
| function handTreeExpand() { | ||
| let treeExpandeds = treeGridRef.value.getTreeExpandeds() | ||
| TinyModal.message({ | ||
| message: `展开行数:${treeExpandeds.length}`, | ||
| status: 'info' | ||
| }) | ||
| } | ||
| </script> | ||
9 changes: 9 additions & 0 deletions
9
examples/sites/demos/pc/app/grid/tree-table/tree-table-tree-grid-expand.spec.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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-tree-table#tree-table-tree-grid-expand') | ||
| await page.getByRole('cell', { name: '1' }).getByRole('img').click() | ||
|
|
||
| await expect(page.getByText('展开行数:1')).toBeVisible() | ||
| }) |
158 changes: 158 additions & 0 deletions
158
examples/sites/demos/pc/app/grid/tree-table/tree-table-tree-grid-expand.vue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,158 @@ | ||
| <template> | ||
| <div> | ||
| <tiny-grid | ||
| ref="treeGrid" | ||
| :data="tableData" | ||
| :tree-config="{ children: 'children' }" | ||
| @toggle-tree-change="handTreeExpand" | ||
| > | ||
| <tiny-grid-column type="index" width="80" tree-node></tiny-grid-column> | ||
| <tiny-grid-column field="name" title="公司名称"></tiny-grid-column> | ||
| <tiny-grid-column field="area" title="区域"></tiny-grid-column> | ||
| <tiny-grid-column field="employees" title="员工数"></tiny-grid-column> | ||
| </tiny-grid> | ||
| </div> | ||
| </template> | ||
|
|
||
| <script lang="jsx"> | ||
| import { TinyGrid, TinyGridColumn, TinyModal } from '@opentiny/vue' | ||
|
|
||
| export default { | ||
| components: { | ||
| TinyGrid, | ||
| TinyGridColumn | ||
| }, | ||
| data() { | ||
| return { | ||
| tableData: [ | ||
| { | ||
| id: '1', | ||
| pid: '0', | ||
| name: 'GFD 科技 YX 公司', | ||
| area: '华东区', | ||
| employees: '800', | ||
| introduction: '公司技术和研发实力雄厚,是国家 863 项目的参与者,并被政府认定为“高新技术企业”。', | ||
| children: [ | ||
| { | ||
| id: '15', | ||
| pid: '1', | ||
| name: 'GFD 科技股份有限子公司', | ||
| area: '华东区', | ||
| employees: '700', | ||
| introduction: '公司技术和研发实力雄厚,是国家 863 项目的参与者,并被政府认定为“高新技术企业”。' | ||
| } | ||
| ] | ||
| }, | ||
| { | ||
| id: '2', | ||
| pid: '0', | ||
| name: 'WWWW 科技 YX 公司', | ||
| area: '华南区', | ||
| employees: '500', | ||
| introduction: '公司技术和研发实力雄厚,是国家 863 项目的参与者,并被政府认定为“高新技术企业”。', | ||
| children: [ | ||
| { | ||
| id: '22', | ||
| pid: '2', | ||
| name: 'WWWW 科技股份有限子公司', | ||
| area: '华南区', | ||
| employees: '720', | ||
| introduction: '公司技术和研发实力雄厚,是国家 863 项目的参与者,并被政府认定为“高新技术企业”。' | ||
| } | ||
| ] | ||
| }, | ||
| { | ||
| id: '4', | ||
| pid: '0', | ||
| name: 'TGBYX 公司', | ||
| area: '华南区', | ||
| employees: '360', | ||
| introduction: '公司技术和研发实力雄厚,是国家 863 项目的参与者,并被政府认定为“高新技术企业”。', | ||
| children: [ | ||
| { | ||
| id: '3', | ||
| pid: '4', | ||
| name: 'RFV 有限责任公司', | ||
| area: '华南区', | ||
| employees: '300', | ||
| introduction: '公司技术和研发实力雄厚,是国家 863 项目的参与者,并被政府认定为“高新技术企业”。' | ||
| }, | ||
| { | ||
| id: '5', | ||
| pid: '4', | ||
| name: 'YHN 科技 YX 公司', | ||
| area: '华南区', | ||
| employees: '810', | ||
| introduction: '公司技术和研发实力雄厚,是国家 863 项目的参与者,并被政府认定为“高新技术企业”。', | ||
| children: [ | ||
| { | ||
| id: '6', | ||
| pid: '5', | ||
| name: 'WSX 科技 YX 公司', | ||
| area: '华南区', | ||
| employees: '800', | ||
| introduction: '公司技术和研发实力雄厚,是国家 863 项目的参与者,并被政府认定为“高新技术企业”。' | ||
| }, | ||
| { | ||
| id: '9', | ||
| pid: '5', | ||
| name: 'UJM 有限责任公司', | ||
| area: '华南区', | ||
| employees: '750', | ||
| introduction: '公司技术和研发实力雄厚,是国家 863 项目的参与者,并被政府认定为“高新技术企业”。' | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| }, | ||
| { | ||
| id: '7', | ||
| pid: '0', | ||
| name: '康康物业 YX 公司', | ||
| area: '华南区', | ||
| employees: '400', | ||
| introduction: '公司技术和研发实力雄厚,是国家 863 项目的参与者,并被政府认定为“高新技术企业”。', | ||
| children: [ | ||
| { | ||
| id: '8', | ||
| pid: '7', | ||
| name: '深圳市福德宝网络技术 YX 公司', | ||
| area: '华南区', | ||
| employees: '540', | ||
| introduction: '公司技术和研发实力雄厚,是国家 863 项目的参与者,并被政府认定为“高新技术企业”。' | ||
| }, | ||
| { | ||
| id: '10', | ||
| pid: '7', | ||
| name: 'IK 有限责任公司', | ||
| area: '华南区', | ||
| employees: '400', | ||
| introduction: '公司技术和研发实力雄厚,是国家 863 项目的参与者,并被政府认定为“高新技术企业”。', | ||
| children: [ | ||
| { | ||
| id: '23', | ||
| pid: '10', | ||
| name: 'IK 有限责任股份 YX 公司', | ||
| area: '华南区', | ||
| employees: '455', | ||
| introduction: '公司技术和研发实力雄厚,是国家 863 项目的参与者,并被政府认定为“高新技术企业”。' | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
| }, | ||
| methods: { | ||
| handTreeExpand() { | ||
| let treeExpandeds = this.$refs.treeGrid.getTreeExpandeds() | ||
|
|
||
| TinyModal.message({ | ||
| message: `展开行数:${treeExpandeds.length}`, | ||
| status: 'info' | ||
| }) | ||
| } | ||
| } | ||
| } | ||
| </script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.