UNPKG

5.35 kBTypeScriptView Raw
1import { ElementUIComponent } from './component'
2import { TooltipEffect } from './tooltip'
3
4export type SortOrder = 'ascending' | 'descending'
5
6/** Options to set the default sort column and order */
7export interface DefaultSortOptions {
8 /** Default sort column */
9 prop: string,
10
11 /** Default sort order */
12 order: SortOrder
13}
14
15export interface SummaryMethodParams {
16 columns: object[],
17 data: object
18}
19
20export interface rowCallbackParams {
21 row: object,
22 rowIndex: number
23}
24
25export interface cellCallbackParams {
26 row: object,
27 rowIndex: number,
28 column: object,
29 columnIndex: number
30}
31
32/** Table Component */
33export declare class ElTable extends ElementUIComponent {
34 /** Table data */
35 data: object[]
36
37 /** Table's height. By default it has an auto height. If its value is a number, the height is measured in pixels; if its value is a string, the height is affected by external styles */
38 height: string | number
39
40 /** Table's max-height. The height of the table starts from auto until it reaches the maxHeight limit. The maxHeight is measured in pixels, same as height */
41 maxHeight: string | number
42
43 /** Whether table is striped */
44 stripe: boolean
45
46 /** Whether table has vertical border */
47 border: boolean
48
49 /** Whether width of column automatically fits its container */
50 fit: boolean
51
52 /** Whether table header is visible */
53 showHeader: boolean
54
55 /** Whether current row is highlighted */
56 highlightCurrentRow: boolean
57
58 /** Key of current row, a set only prop */
59 currentRowKey: string | number
60
61 /** Function that returns custom class names for a row, or a string assigning class names for every row */
62 rowClassName: string | ((param: rowCallbackParams) => string)
63
64 /** Function that returns custom style for a row, or an object assigning custom style for every row */
65 rowStyle: object | ((param: rowCallbackParams) => object)
66
67 /** Function that returns custom class names for a cell, or a string assigning class names for every cell */
68 cellClassName: string | ((param: cellCallbackParams) => string)
69
70 /** Function that returns custom style for a cell, or an object assigning custom style for every cell */
71 cellStyle: object | ((param: cellCallbackParams) => object)
72
73 /** Function that returns custom class names for a row in table header, or a string assigning class names for every row in table header */
74 headerRowClassName: string | ((param: rowCallbackParams) => string)
75
76 /** Function that returns custom style for a row in table header, or an object assigning custom style for every row in table header */
77 headerRowStyle: object | ((param: rowCallbackParams) => object)
78
79 /** Function that returns custom class names for a cell in table header, or a string assigning class names for every cell in table header */
80 headerCellClassName: string | ((param: cellCallbackParams) => string)
81
82 /** Function that returns custom style for a cell in table header, or an object assigning custom style for every cell in table header */
83 headerCellStyle: object | ((param: cellCallbackParams) => object)
84
85 /** Key of row data, used for optimizing rendering. Required if reserve-selection is on */
86 rowKey: (row: object) => any
87
88 /** Displayed text when data is empty. You can customize this area with `slot="empty"` */
89 emptyText: String
90
91 /** Whether expand all rows by default. Only works when the table has a column `type="expand"` */
92 defaultExpandAll: Boolean
93
94 /** Set expanded rows by this prop. Prop's value is the keys of expand rows, you should set row-key before using this prop */
95 expandRowKeys: any[]
96
97 /** Set the default sort column and order */
98 defaultSort: DefaultSortOptions
99
100 /** Tooltip effect property */
101 tooltipEffect: TooltipEffect
102
103 /** Whether to display a summary row */
104 showSummary: boolean
105
106 /** Displayed text for the first column of summary row */
107 sumText: string
108
109 /** Custom summary method */
110 summaryMethod: (param: SummaryMethodParams) => any[]
111
112 /** Controls the behavior of master checkbox in multi-select tables when only some rows are selected */
113 selectOnIndeterminate: boolean
114
115 /** Clear selection. Might be useful when `reserve-selection` is on */
116 clearSelection (): void
117
118 /**
119 * Toggle or set if a certain row is selected
120 *
121 * @param row The row that is going to set its selected state
122 * @param selected Whether the row is selected. The selected state will be toggled if not set
123 */
124 toggleRowSelection (row: object, selected?: boolean): void
125
126 /**
127 * Toggle or set all rows
128 */
129 toggleAllSelection (): void
130
131 /**
132 * Set a certain row as selected
133 *
134 * @param row The row that is going to set as selected
135 */
136 setCurrentRow (row?: object): void
137
138 /**
139 * Toggle or set if a certain row is expanded
140 *
141 * @param row The row that is going to set its expanded state
142 * @param expanded Whether the row is expanded. The expanded state will be toggled if not set
143 */
144 toggleRowExpansion (row: object, expanded?: boolean): void
145
146 /** Clear sort status, reset the table to unsorted */
147 clearSort (): void
148
149 /** Clear filter, reset the table to unfiltered */
150 clearFilter (): void
151
152 /** Relayout the table, maybe needed when change the table or it's ancestors visibility */
153 doLayout (): void
154
155 /** Sort Table manually */
156 sort (prop: string, order: string): void
157}