瀏覽代碼

Table: support header_options

master
Bing Sun 5 年之前
父節點
當前提交
7ec755703a
簽署人: sunb GPG 金鑰 ID: F7795F8C590626AB
共有 1 個檔案被更改,包括 12 行新增1 行删除
  1. +12
    -1
      src/components/Table.js

+ 12
- 1
src/components/Table.js 查看文件

@@ -94,8 +94,18 @@ export default initial_vnode => {
// always show table header
m('thead', m('tr', [
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
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,
@@ -112,6 +122,7 @@ export default initial_vnode => {
})
]))) : m('', 'Empty')
]),

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


Loading…
取消
儲存