Skip to content

Commit

Permalink
Fix column formater
Browse files Browse the repository at this point in the history
  • Loading branch information
kinglisky committed Nov 7, 2017
1 parent 34d296f commit 5efe54e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
3 changes: 1 addition & 2 deletions README.md
Expand Up @@ -38,8 +38,7 @@ import Egrid from 'egrid'
import 'element-ui/lib/theme-default/icon.css'
import 'element-ui/lib/theme-default/table.css'
import 'element-ui/lib/theme-default/table-column.css'
//
import 'element-ui/lib/theme-default/index.css'




Expand Down
19 changes: 11 additions & 8 deletions dev/App.vue
Expand Up @@ -7,7 +7,6 @@
:data="data"
:columns="columns"
:columns-schema="columnsSchema"
:columns-props="columnsProps"
:columns-handler="columnsHandler"
@selection-change="selectionChange">
<template slot="expand" slot-scope="{ row }">
Expand All @@ -28,7 +27,6 @@ import Egrid from '../src/index'
import Data from './data'
import Btn from './cell-btn.vue'
import Editor from './cell-editor.vue'
console.log(Egrid)
export default {
name: 'app',
data () {
Expand All @@ -37,12 +35,12 @@ export default {
columns: Data.columns,
// columnsProps 用于定义所有 columns 公共的属性,
// 这里属性可以参考这里: http://element.eleme.io/#/zh-CN/component/table#table-column-attributes
columnsProps: {
width: 120,
sortable: true,
// 定义表格列如何渲染
component: Editor
},
// columnsProps: {
// width: 120,
// sortable: true,
// // 定义表格列如何渲染
// component: Editor
// },
// columnsSchema 可以用来单独定义 columns 的某一列,这里的设置会覆盖 columnsProps 的配置属性
columnsSchema: {
Expand All @@ -60,6 +58,11 @@ export default {
}, this.address)
}
})
},
'邮编': {
formater (row, col) {
return row[col.prop] + '...'
}
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/text.js
@@ -1,8 +1,9 @@

export default {
functional: true,
props: ['row', 'col'],
props: ['row', 'col', 'column'],
render (h, { props: { row, col } }) {
return row[col.prop]
const { formater } = col
return formater && formater(row, col) || row[col.prop]
}
}

0 comments on commit 5efe54e

Please sign in to comment.