table.d.ts 5.6 KB

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