-
-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
using SetColSpan/SetRowSpan produce unnalligned tables #11
Comments
Hi, add new component type: type spanImpl struct {
compImpl // Component implementation
}
func NewSpan() Comp {
return &spanImpl{ newCompImpl(nil) }
}
func (c *spanImpl) Render(w writer) {
panic("must not be called")
} and check in tableImpl Render: func (c *tableImpl) Render(w writer) {
w.Write(_STR_TABLE_OP)
c.renderAttrsAndStyle(w)
c.renderEHandlers(w)
w.Write(_STR_GT)
// Create a reusable cell index
ci := cellIdx{}
for row, rowComps := range c.comps {
c.renderRowTr(row, w)
for col, c2 := range rowComps {
if _, ok := c2.(*spanImpl); !ok {
ci.row, ci.col = row, col
c.renderTd(ci, w)
if c2 != nil {
c2.Render(w)
}
}
}
}
w.Write(_STR_TABLE_CL)
} and manually insert this type in cells you dont want to render:
what you mind ? Regards. |
Will check your suggestion later when I have a chance. |
I'm not sure what you feel is wrong. I think the current behavior is correct. It follows the HTML table behavior. Since all rows have 5 cells (5 values), and in the 3rd row (row idx=2) there is one cell which spawns to 2 columns, then the 3rd row will "reach beyond" the 2nd (will have an "extra" column over the 2nd for example). |
may be not wrong, but i want rectangular table. |
Ok, let's see an example. Using
The 2nd row contains 2 cells, first having The "same" (same in structure) table generated with HTML:
The raw HTML code formatted:
I still think this is correct. Please explain in this example what you think is wrong. |
but this sequence: t.Add(gwu.NewLabel("00-01"), 0, 0)
t.SetColSpan(0,0,2)
t.Add(gwu.NewLabel("02"), 0, 1)
t.Add(gwu.NewLabel("10"), 1, 0)
t.Add(gwu.NewLabel("11"), 1, 1)
t.Add(gwu.NewLabel("12"), 1, 2) doesn't work because Add call internally EnsureSize |
Have you tried it? Because your example code does work!
|
yes, i tried it. inspecting source in browser is:
|
to see visually extra cell, please try: t := gwu.NewTable()
t.SetCellSpacing(3)
t.SetCellPadding(30)
t.Add(gwu.NewLabel("00-01"), 0, 0)
t.SetColSpan(0,0,2)
t.Add(gwu.NewLabel("02"), 0, 1)
t.Add(gwu.NewLabel("10"), 1, 0)
t.Add(gwu.NewLabel("11"), 1, 1)
t.Add(gwu.NewLabel("12"), 1, 2)
t.RowFmt(0).Style().SetBackground("#bbaa99")
t.RowFmt(1).Style().SetBackground("#bbaa99") |
ok, imho instead of
should be
|
Ok, now I see your concern, which is valid. And you're proposed fix looks good and elegant! |
But actually I'm gonna implement a |
Thanks for reporting this, it is now fixed on gowut.dev: |
I also thank, |
Hi,
in example 'Gowut - Showcase of Features'/'Advanced table structure with modified alignment, row and col spans' (see table container)
I expect cells 22 and 41 to miss and example table to be rectangular.
If i not set content for cells 2,2 & 4,1 gowut still produce empty
<td></td>
The text was updated successfully, but these errors were encountered: