docs: update table-v2 demo (#10059)

This commit is contained in:
zz
2022-10-12 16:15:06 +08:00
committed by GitHub
parent 31f713bf1b
commit efed80666d
2 changed files with 14 additions and 14 deletions

View File

@@ -15,18 +15,17 @@
</template>
<script lang="tsx" setup>
import { nextTick, ref, resolveDynamicComponent } from 'vue'
import { ref } from 'vue'
import { ElInput } from 'element-plus'
import type { FunctionalComponent } from 'vue'
import type { Column, ElInput } from 'element-plus'
const Input = resolveDynamicComponent('ElInput') as typeof ElInput
import type { Column, InputInstance } from 'element-plus'
type SelectionCellProps = {
value: string
intermediate?: boolean
onChange: (value: string) => void
forwardRef: (el: InstanceType<typeof ElInput>) => void
forwardRef: (el: InputInstance) => void
}
const InputCell: FunctionalComponent<SelectionCellProps> = ({
@@ -34,7 +33,9 @@ const InputCell: FunctionalComponent<SelectionCellProps> = ({
onChange,
forwardRef,
}) => {
return <Input ref={forwardRef as any} onInput={onChange} modelValue={value} />
return (
<ElInput ref={forwardRef as any} onInput={onChange} modelValue={value} />
)
}
const generateColumns = (length = 10, prefix = 'column-', props?: any) =>

View File

@@ -15,17 +15,16 @@
</template>
<script lang="tsx" setup>
import { ref, resolveDynamicComponent, unref } from 'vue'
import { ref, unref } from 'vue'
import { ElCheckbox } from 'element-plus'
import type { FunctionalComponent } from 'vue'
import type { Column, ElCheckbox } from 'element-plus'
const Checkbox = resolveDynamicComponent('ElCheckbox') as typeof ElCheckbox
import type { CheckboxValueType, Column } from 'element-plus'
type SelectionCellProps = {
value: boolean
intermediate?: boolean
onChange: (value: boolean) => void
onChange: (value: CheckboxValueType) => void
}
const SelectionCell: FunctionalComponent<SelectionCellProps> = ({
@@ -34,7 +33,7 @@ const SelectionCell: FunctionalComponent<SelectionCellProps> = ({
onChange,
}) => {
return (
<Checkbox
<ElCheckbox
onChange={onChange}
modelValue={value}
indeterminate={intermediate}
@@ -75,13 +74,13 @@ columns.unshift({
key: 'selection',
width: 50,
cellRenderer: ({ rowData }) => {
const onChange = (value: boolean) => (rowData.checked = value)
const onChange = (value: CheckboxValueType) => (rowData.checked = value)
return <SelectionCell value={rowData.checked} onChange={onChange} />
},
headerCellRenderer: () => {
const _data = unref(data)
const onChange = (value: boolean) =>
const onChange = (value: CheckboxValueType) =>
(data.value = _data.map((row) => {
row.checked = value
return row