forked from opentiny/tiny-vue
docs(grid): add new getStateSelection api (#1972)
* docs(grid): add new getStateSelection api * docs(grid): add new getStateSelection api
This commit is contained in:
parent
963b5f11a2
commit
2b643a106a
|
@ -2305,13 +2305,28 @@ export default {
|
|||
mode: ['mobile-first'],
|
||||
mfDemo: ''
|
||||
},
|
||||
{
|
||||
name: 'getAllSelection',
|
||||
typeAnchorName: 'IRow',
|
||||
type: '() => IRow[]',
|
||||
meta: {
|
||||
stable: '3.19.0'
|
||||
},
|
||||
defaultValue: '',
|
||||
desc: {
|
||||
'zh-CN': '获取所有翻页中保存的已选中的数据',
|
||||
'en-US': 'This command is used to select multiple lines to obtain the selected data.'
|
||||
},
|
||||
mode: ['pc'],
|
||||
pcDemo: 'grid-operation-column#operation-column-grid-pager-reserve'
|
||||
},
|
||||
{
|
||||
name: 'getSelectRecords',
|
||||
typeAnchorName: 'IRow',
|
||||
type: '() => IRow[]',
|
||||
defaultValue: '',
|
||||
desc: {
|
||||
'zh-CN': '用于多选行,获取已选中的数据',
|
||||
'zh-CN': '用于多选行,获取当前页已选中的数据',
|
||||
'en-US': 'This command is used to select multiple lines to obtain the selected data.'
|
||||
},
|
||||
mode: ['pc'],
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
<template>
|
||||
<div>
|
||||
<tiny-button @click="getAllSelection">获取所有选中项</tiny-button>
|
||||
<br /><br />
|
||||
<tiny-grid
|
||||
ref="gridRef"
|
||||
:fetch-data="fetchData"
|
||||
row-id="id"
|
||||
seq-serial
|
||||
|
@ -20,7 +23,14 @@
|
|||
|
||||
<script setup lang="jsx">
|
||||
import { ref } from 'vue'
|
||||
import { Grid as TinyGrid, GridColumn as TinyGridColumn, Pager, Notify } from '@opentiny/vue'
|
||||
import {
|
||||
Grid as TinyGrid,
|
||||
GridColumn as TinyGridColumn,
|
||||
Pager,
|
||||
Notify,
|
||||
Modal,
|
||||
Button as TinyButton
|
||||
} from '@opentiny/vue'
|
||||
|
||||
const tableSelectConfigData = ref({
|
||||
// 翻页时记住选择项,必须同时配置row-id
|
||||
|
@ -44,6 +54,13 @@ const fetchData = ref({
|
|||
api: getData
|
||||
})
|
||||
|
||||
const gridRef = ref()
|
||||
|
||||
function getAllSelection() {
|
||||
const selection = gridRef.value.getAllSelection()
|
||||
Modal.message({ status: 'info', message: `一共选中了${selection.length}项数据` })
|
||||
}
|
||||
|
||||
function getTableData() {
|
||||
return [
|
||||
{
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
<template>
|
||||
<div>
|
||||
<tiny-button @click="getAllSelection">获取所有选中项</tiny-button>
|
||||
<br /><br />
|
||||
<tiny-grid
|
||||
ref="grid"
|
||||
:fetch-data="fetchData"
|
||||
row-id="id"
|
||||
seq-serial
|
||||
|
@ -19,12 +22,13 @@
|
|||
</template>
|
||||
|
||||
<script lang="jsx">
|
||||
import { Grid, GridColumn, Pager, Notify } from '@opentiny/vue'
|
||||
import { Grid, GridColumn, Pager, Notify, Button, Modal } from '@opentiny/vue'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
TinyGrid: Grid,
|
||||
TinyGridColumn: GridColumn
|
||||
TinyGridColumn: GridColumn,
|
||||
TinyButton: Button
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
|
@ -52,6 +56,10 @@ export default {
|
|||
}
|
||||
},
|
||||
methods: {
|
||||
getAllSelection() {
|
||||
const selection = this.$refs.grid.getAllSelection()
|
||||
Modal.message({ status: 'info', message: `一共选中了${selection.length}项数据` })
|
||||
},
|
||||
getTableData() {
|
||||
return [
|
||||
{
|
||||
|
|
|
@ -56,9 +56,9 @@ export default {
|
|||
'name': { 'zh-CN': '翻页后保留选中状态', 'en-US': 'Manually select a line' },
|
||||
'desc': {
|
||||
'zh-CN':
|
||||
'<p>通过配置<code>select-config</code>中的<code>reserve</code>为<code>true</code> 并设置<code>row-id</code>,开启翻页后保留选中状态功能。</p>\n',
|
||||
'<p>通过设置 <code>select-config</code> 中的 <code>reserve</code> 为 <code>true</code> 并设置 <code>row-id</code>,开启翻页后保留选中状态功能。通过 <code>getAllSelection</code> 获取所有翻页选中数据。</p>\n',
|
||||
'en-US':
|
||||
'<p> <code>setRadioRow(row)</code> is used to select a single line and set the selected status of a line. </p>\n'
|
||||
'<p>By setting the <code>reserve</code> in <code>select-config</code> to <code>true</code> and setting <code>row-id</code>, you can enable the function of keeping the selected state after page turning. Get all flip selection data via <code>getAllSelection</code>.</p>\n'
|
||||
},
|
||||
'codeFiles': ['operation-column/grid-pager-reserve.vue']
|
||||
},
|
||||
|
|
|
@ -2048,8 +2048,8 @@ const Methods = {
|
|||
|
||||
return columnIds.join(',')
|
||||
},
|
||||
// 获取多选数据状态,避免用户侧很长的调用 this.$refs.grid.$refs.auiTable.selection
|
||||
getStateSelection() {
|
||||
// 获取所有多选数据状态
|
||||
getAllSelection() {
|
||||
return this.selection
|
||||
},
|
||||
// 尝试恢复滚动位置,规范了最大滚动位置的取值
|
||||
|
|
Loading…
Reference in New Issue