Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export type Formatter = (row: DefaultRow, column: Column, cellValue: any, rowInd

export type CompareFn<T = any> = (field: string, a: T, b: T) => boolean;

export type ColumnType = 'checkable' | '';
export type ColumnType = 'checkable' | 'index' | '';

export interface FilterConfig {
id: number | string;
Expand All @@ -23,7 +23,6 @@ export const tableColumnProps = {
},
header: {
type: String,
default: '',
},
field: {
type: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,12 @@ export const cellMap = {
});
},
},
index: {
renderHeader(column: Column): VNode {
return h('span', { class: 'title' }, column.header ?? '#');
},
renderCell(rowData: DefaultRow, column: Column, store: TableStore, rowIndex: number): number {
return rowIndex + 1;
},
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function createColumn(props: ToRefs<TableColumnProps>, templates: Slots):
column.type = type.value;

function defaultRenderHeader(columnItem: Column) {
return h('span', { class: 'title' }, columnItem.header);
return h('span', { class: 'title' }, columnItem.header ?? '');
}

function defaultRenderCell(rowData: DefaultRow, columnItem: Column, store: TableStore, rowIndex: number) {
Expand Down
1 change: 1 addition & 0 deletions packages/devui-vue/docs/components/table/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
```vue
<template>
<d-table :data="baseTableData">
<d-column type="index"></d-column>
<d-column field="firstName" header="First Name"></d-column>
<d-column field="lastName" header="Last Name"></d-column>
<d-column field="gender" header="Gender"></d-column>
Expand Down