table.d.ts 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. /** Clear selection. Might be useful when `reserve-selection` is on */
  58. clearSelection (): void
  59. /**
  60. * Toggle or set if a certain row is selected
  61. *
  62. * @param row The row that is going to set its selected state
  63. * @param selected Whether the row is selected. The selected state will be toggled if not set
  64. */
  65. toggleRowSelection (row: object, selected?: boolean): void
  66. /**
  67. * Set a certain row as selected
  68. *
  69. * @param row The row that is going to set as selected
  70. */
  71. setCurrentRow (row?: object): void
  72. }