Browse Source

Table: support header_options

master
Bing Sun 5 years ago
parent
commit
7ec755703a
Signed by: sunb GPG Key ID: F7795F8C590626AB
1 changed files with 12 additions and 1 deletions
  1. +12
    -1
      src/components/Table.js

+ 12
- 1
src/components/Table.js View File

@@ -94,8 +94,18 @@ export default initial_vnode => {
// always show table header // always show table header
m('thead', m('tr', [ m('thead', m('tr', [
vnode.attrs.serial ? m('th.centered', '序号') : undefined, vnode.attrs.serial ? m('th.centered', '序号') : undefined,
...columns.map(column => m('th.centered', column.label))
...columns.map(column => {
let el = column.label

if (vnode.attrs.header_options && vnode.attrs.header_options[column.label]) {
if (typeof vnode.attrs.header_options[column.label].producer == 'function')
el = vnode.attrs.header_options[column.label].producer(el)
}

return m('th.centered', el)
})
])), ])),

// table content // table content
model.data(offset, limit).length ? m('tbody', model.data(offset, limit).map((row, i) => m('tr', [ model.data(offset, limit).length ? m('tbody', model.data(offset, limit).map((row, i) => m('tr', [
vnode.attrs.serial ? m('td.centered', offset+i+1) : undefined, vnode.attrs.serial ? m('td.centered', offset+i+1) : undefined,
@@ -112,6 +122,7 @@ export default initial_vnode => {
}) })
]))) : m('', 'Empty') ]))) : m('', 'Empty')
]), ]),

// page navigation // page navigation
pages.length > 1 && vnode.attrs.show ? pages.length > 1 && vnode.attrs.show ?
m('.centered', m('.centered',


Loading…
Cancel
Save