]> saetta.ns0.it Git - zakgrid_go/commitdiff
Taking into account column property align.
authorAndrea Zagli <azagli@libero.it>
Sun, 22 Aug 2021 07:02:25 +0000 (09:02 +0200)
committerAndrea Zagli <azagli@libero.it>
Sun, 22 Aug 2021 07:02:25 +0000 (09:02 +0200)
main.go

diff --git a/main.go b/main.go
index 7de1eefe5c8ffd0de5e22335e3bcbe8d501d2e4d..40096a93fbb1ef534f33fba55e13f5d2044ff861 100644 (file)
--- a/main.go
+++ b/main.go
@@ -47,7 +47,15 @@ func (g *grid) getRowFromDb (m map[string]interface{}) string {
                                v = c.toCall(m)
                        }
                }
-               ret += fmt.Sprintf("\t<td>%v</td>\n", v)
+
+               align := ""
+               if c.align == 1 {
+                       align = " align='center'"
+               } else if c.align == 2 {
+                       align = " align='right'"
+               }
+
+               ret += fmt.Sprintf("\t<td%s>%v</td>\n", align, v)
        }
 
        ret += "</tr>\n"
@@ -78,6 +86,7 @@ func main() {
 
        c = column{name: "btn", title: "Buttons"}
        c.toCall = missing
+       c.align = 2
        g.addColumn(c)
 
        fmt.Println (g)