table-column.d.ts 3.8 KB

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