table-column.d.ts 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. import { CreateElement, VNode } from 'vue'
  2. import { ElementUIComponent, ElementUIHorizontalAlignment } from './component'
  3. import { PopoverPlacement } from './popover'
  4. export type TableColumnType = 'default' | 'selection' | 'index' | 'expand'
  5. export type TableColumnFixedType = 'left' | 'right'
  6. export type TableColumn = {
  7. /** Label of the column */
  8. label: string,
  9. /** Property name of the source data */
  10. property: string,
  11. /** Type of the column */
  12. type: string,
  13. /** Whether column is fixed at left/right */
  14. fixed: boolean | string
  15. }
  16. /** Data used in renderHeader function */
  17. export interface RenderHeaderData {
  18. /** The column that is current rendering */
  19. column: any,
  20. /** The index of the rendering column */
  21. $index: number
  22. }
  23. /** Filter Object */
  24. export interface TableColumnFilter {
  25. /** The text to show in the filter's panel */
  26. text: string,
  27. /** The value of the filter */
  28. value: any
  29. }
  30. /** TableColumn Component */
  31. export declare class ElTableColumn extends ElementUIComponent {
  32. /** Type of the column. If set to `selection`, the column will display checkbox. If set to `index`, the column will display index of the row (staring from 1). If set to `expand`, the column will display expand icon. */
  33. type: TableColumnType
  34. /** Column label */
  35. label: string
  36. /** Column's key. If you need to use the filter-change event, you need this attribute to identify which column is being filtered */
  37. columnKey: string
  38. /** Field name. You can also use its alias: property */
  39. prop: string
  40. /** Column width */
  41. width: string
  42. /** Column minimum width. Columns with `width` has a fixed width, while columns with `min-width` has a width that is distributed in proportion */
  43. minWidth: string
  44. /** Whether column is fixed at left/right. Will be fixed at left if `true` */
  45. fixed: boolean | TableColumnFixedType
  46. /** Render function for table header of this column */
  47. renderHeader: (h: CreateElement, data: RenderHeaderData) => VNode | string
  48. /** Whether column can be sorted */
  49. sortable: boolean
  50. /** Sorting method. Works when `sortable` is `true` */
  51. sortMethod: (a: any, b: any) => number
  52. /** Whether column width can be resized. Works when border of `el-table` is `true` */
  53. resizable: boolean
  54. /** Function that formats content */
  55. formatter: (row: object, column: TableColumn) => any
  56. /** Whether to hide extra content and show them in a tooltip when hovering on the cell */
  57. showOverflowTooltip: boolean
  58. /** Alignment */
  59. align: ElementUIHorizontalAlignment
  60. /** Alignment of the table header. If omitted, the value of the `align` attribute will be applied */
  61. headerAlign: ElementUIHorizontalAlignment
  62. /** Class name of cells in the column */
  63. className: string
  64. /** Class name of the label of this column */
  65. labelClassName: string
  66. /** Function that determines if a certain row can be selected, works when `type` is `'selection'` */
  67. selectable: (row: object, index: number) => boolean
  68. /** Whether to reserve selection after data refreshing, works when `type` is `'selection'` */
  69. reserveSelection: boolean
  70. /** An array of data filtering options */
  71. filters: TableColumnFilter[]
  72. /** Placement for the filter dropdown */
  73. filterPlacement: PopoverPlacement
  74. /** Whether data filtering supports multiple options */
  75. filterMultiple: Boolean
  76. /** Data filtering method. If `filter-multiple` is on, this method will be called multiple times for each row, and a row will display if one of the calls returns `true` */
  77. filterMethod: (value: any, row: object) => boolean
  78. /** Filter value for selected data, might be useful when table header is rendered with `render-header` */
  79. filteredValue: TableColumnFilter[]
  80. }