table.d.ts 3.7 KB

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