table-column.d.ts 3.3 KB

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