table.d.ts 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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. /** Table Component */
  26. export declare class ElTable extends ElementUIComponent {
  27. /** Table data */
  28. data: object[]
  29. /** 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 */
  30. height: string | number
  31. /** 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 */
  32. maxHeight: string | number
  33. /** Whether table is striped */
  34. stripe: boolean
  35. /** Whether table has vertical border */
  36. border: boolean
  37. /** Whether width of column automatically fits its container */
  38. fit: boolean
  39. /** Whether table header is visible */
  40. showHeader: boolean
  41. /** Whether current row is highlighted */
  42. highlightCurrentRow: boolean
  43. /** Key of current row, a set only prop */
  44. currentRowKey: string | number
  45. /** Function that returns custom class names for a row, or a string assigning class names for every row */
  46. rowClassName: string | ((param: rowCallbackParams) => string)
  47. /** Function that returns custom style for a row, or an object assigning custom style for every row */
  48. rowStyle: object | ((param: rowCallbackParams) => object)
  49. /** Function that returns custom class names for a cell, or a string assigning class names for every cell */
  50. cellClassName: string | ((param: cellCallbackParams) => string)
  51. /** Function that returns custom style for a cell, or an object assigning custom style for every cell */
  52. cellStyle: object | ((param: cellCallbackParams) => object)
  53. /** Function that returns custom class names for a row in table header, or a string assigning class names for every row in table header */
  54. headerRowClassName: string | ((param: rowCallbackParams) => string)
  55. /** Function that returns custom style for a row in table header, or an object assigning custom style for every row in table header */
  56. headerRowStyle: object | ((param: rowCallbackParams) => object)
  57. /** Function that returns custom class names for a cell in table header, or a string assigning class names for every cell in table header */
  58. headerCellClassName: string | ((param: cellCallbackParams) => string)
  59. /** Function that returns custom style for a cell in table header, or an object assigning custom style for every cell in table header */
  60. headerCellStyle: object | ((param: cellCallbackParams) => object)
  61. /** Key of row data, used for optimizing rendering. Required if reserve-selection is on */
  62. rowKey: (row: object) => any
  63. /** Displayed text when data is empty. You can customize this area with `slot="empty"` */
  64. emptyText: String
  65. /** Whether expand all rows by default. Only works when the table has a column `type="expand"` */
  66. defaultExpandAll: Boolean
  67. /** Set expanded rows by this prop. Prop's value is the keys of expand rows, you should set row-key before using this prop */
  68. expandRowKeys: any[]
  69. /** Set the default sort column and order */
  70. defaultSort: DefaultSortOptions
  71. /** Tooltip effect property */
  72. tooltipEffect: TooltipEffect
  73. /** Whether to display a summary row */
  74. showSummary: boolean
  75. /** Displayed text for the first column of summary row */
  76. sumText: string
  77. /** Custom summary method */
  78. summaryMethod: (param: SummaryMethodParams) => any[]
  79. /** Controls the behavior of master checkbox in multi-select tables when only some rows are selected */
  80. selectOnIndeterminate: boolean
  81. /** Clear selection. Might be useful when `reserve-selection` is on */
  82. clearSelection (): void
  83. /**
  84. * Toggle or set if a certain row is selected
  85. *
  86. * @param row The row that is going to set its selected state
  87. * @param selected Whether the row is selected. The selected state will be toggled if not set
  88. */
  89. toggleRowSelection (row: object, selected?: boolean): void
  90. /**
  91. * Set a certain row as selected
  92. *
  93. * @param row The row that is going to set as selected
  94. */
  95. setCurrentRow (row?: object): void
  96. /**
  97. * Toggle or set if a certain row is expanded
  98. *
  99. * @param row The row that is going to set its expanded state
  100. * @param expanded Whether the row is expanded. The expanded state will be toggled if not set
  101. */
  102. toggleRowExpansion (row: object, expanded?: boolean): void
  103. /** Clear sort status, reset the table to unsorted */
  104. clearSort (): void
  105. /** Clear filter, reset the table to unfiltered */
  106. clearFilter (): void
  107. /** Relayout the table, maybe needed when change the table or it's ancestors visibility */
  108. doLayout (): void
  109. /** Sort Table manually */
  110. sort (prop: string, order: string): void
  111. }