-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(data-table): add
row-props
prop
- Loading branch information
Showing
9 changed files
with
182 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# Custom Row Props | ||
|
||
If you want to add attr or event handlers to a row, use `row-props` prop. | ||
|
||
```html | ||
<n-data-table :columns="columns" :data="data" :row-props="rowProps" /> | ||
``` | ||
|
||
```js | ||
import { defineComponent } from 'vue' | ||
import { useMessage } from 'naive-ui' | ||
|
||
export default defineComponent({ | ||
setup () { | ||
const message = useMessage() | ||
return { | ||
rowProps: (row) => { | ||
return { | ||
style: 'cursor: pointer;', | ||
onClick: () => { | ||
message.info(row.name) | ||
} | ||
} | ||
}, | ||
columns: [ | ||
{ | ||
title: 'Name', | ||
key: 'name' | ||
}, | ||
{ | ||
title: 'Age', | ||
key: 'age' | ||
}, | ||
{ | ||
title: 'Address', | ||
key: 'address' | ||
} | ||
], | ||
data: [ | ||
{ | ||
key: 0, | ||
name: '07akioni', | ||
age: '18', | ||
address: 'Yiheyuan Road' | ||
}, | ||
{ | ||
key: 1, | ||
name: '08akioni', | ||
age: '14', | ||
address: 'Pingshan Road' | ||
}, | ||
{ | ||
key: 2, | ||
name: '09akioni', | ||
age: '22', | ||
address: 'Haidian Bridge' | ||
} | ||
] | ||
} | ||
} | ||
}) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# 自定义行属性 | ||
|
||
如果你想给行增加一些属性或者事件处理器,使用 `row-props` 属性。 | ||
|
||
```html | ||
<n-data-table :columns="columns" :data="data" :row-props="rowProps" /> | ||
``` | ||
|
||
```js | ||
import { defineComponent } from 'vue' | ||
import { useMessage } from 'naive-ui' | ||
|
||
export default defineComponent({ | ||
setup () { | ||
const message = useMessage() | ||
return { | ||
rowProps: (row) => { | ||
return { | ||
style: 'cursor: pointer;', | ||
onClick: () => { | ||
message.info(row.name) | ||
} | ||
} | ||
}, | ||
columns: [ | ||
{ | ||
title: 'Name', | ||
key: 'name' | ||
}, | ||
{ | ||
title: 'Age', | ||
key: 'age' | ||
}, | ||
{ | ||
title: 'Address', | ||
key: 'address' | ||
} | ||
], | ||
data: [ | ||
{ | ||
key: 0, | ||
name: '07akioni', | ||
age: '18', | ||
address: 'Yiheyuan Road' | ||
}, | ||
{ | ||
key: 1, | ||
name: '08akioni', | ||
age: '14', | ||
address: 'Pingshan Road' | ||
}, | ||
{ | ||
key: 2, | ||
name: '09akioni', | ||
age: '22', | ||
address: 'Haidian Bridge' | ||
} | ||
] | ||
} | ||
} | ||
}) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.