Ability to specify table header when creating table.
This commit is contained in:
parent
6c55dbc690
commit
745743976f
@ -43,6 +43,8 @@ type TableOptions struct {
|
|||||||
IsHoverable bool
|
IsHoverable bool
|
||||||
IsNarrow bool
|
IsNarrow bool
|
||||||
IsStriped bool
|
IsStriped bool
|
||||||
|
|
||||||
|
Header []string
|
||||||
}
|
}
|
||||||
|
|
||||||
// Table is a controlling structure for "table" HTML element.
|
// Table is a controlling structure for "table" HTML element.
|
||||||
@ -108,5 +110,21 @@ func (t *Table) initialize(tableOpts *TableOptions) {
|
|||||||
|
|
||||||
t.InitializeGeneric()
|
t.InitializeGeneric()
|
||||||
|
|
||||||
|
if t.options != nil {
|
||||||
|
if len(t.options.Header) != 0 {
|
||||||
|
theader := NewTHead()
|
||||||
|
t.AddChild(theader)
|
||||||
|
|
||||||
|
trow := NewTR()
|
||||||
|
theader.AddChild(trow)
|
||||||
|
|
||||||
|
for _, header := range t.options.Header {
|
||||||
|
th := NewTH()
|
||||||
|
th.SetTextContent(header)
|
||||||
|
trow.AddChild(th)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
t.Object = js.Global.Get(common.HTMLElementDocument).Call(common.JSCallCreateElement, common.HTMLElementTable)
|
t.Object = js.Global.Get(common.HTMLElementDocument).Call(common.JSCallCreateElement, common.HTMLElementTable)
|
||||||
}
|
}
|
||||||
|
@ -100,6 +100,8 @@ func constructTable(mainDiv *elements.Div) {
|
|||||||
IsFullWidth: true,
|
IsFullWidth: true,
|
||||||
IsHoverable: true,
|
IsHoverable: true,
|
||||||
IsNarrow: true,
|
IsNarrow: true,
|
||||||
|
|
||||||
|
Header: []string{"Header", "Line"},
|
||||||
})
|
})
|
||||||
tableDiv.AddChild(testTable)
|
tableDiv.AddChild(testTable)
|
||||||
|
|
||||||
@ -109,14 +111,6 @@ func constructTable(mainDiv *elements.Div) {
|
|||||||
tableHeaderLine := elements.NewTR()
|
tableHeaderLine := elements.NewTR()
|
||||||
tableHeader.AddChild(tableHeaderLine)
|
tableHeader.AddChild(tableHeaderLine)
|
||||||
|
|
||||||
thlOne := elements.NewTH()
|
|
||||||
thlOne.SetTextContent("Header")
|
|
||||||
tableHeaderLine.AddChild(thlOne)
|
|
||||||
|
|
||||||
thlTwo := elements.NewTH()
|
|
||||||
thlTwo.SetTextContent("line")
|
|
||||||
tableHeaderLine.AddChild(thlTwo)
|
|
||||||
|
|
||||||
tableBody := elements.NewTBody()
|
tableBody := elements.NewTBody()
|
||||||
testTable.AddChild(tableBody)
|
testTable.AddChild(tableBody)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user