datatable

package module
v0.0.0-...-3e72e9e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 14, 2023 License: MIT Imports: 6 Imported by: 0

README

datatable

This packet provides these datatable tools:

  • building Data Table

  • Transposition Tool

    Is a GoLang implementation based on this question.

  • HTML Generator

An Example Application generates this output html page.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultHtmlBuilder = &HtmlBuilder{
	Begin: func(w io.Writer) (err error) {
		_, err = fmt.Fprintf(w, "<table cellspacing=\"0\" border=\"1\">\n\t<tbody>")
		return
	},
	End: func(w io.Writer) (err error) {
		_, err = fmt.Fprintf(w, "\t</tbody>\n</table>\n")
		return
	},
	Row: func(w io.Writer, index int) (close func() error, err error) {
		if _, err = w.Write([]byte("\t\t<tr>\n")); err != nil {
			return
		}
		return func() (err error) {
			_, err = w.Write([]byte("\t\t</tr>\n"))
			return
		}, nil
	},
	Cell: func(w io.Writer, rowIndex, cellIndex int, cell Cell, attrs []string) (err error) {
		if _, err = w.Write([]byte("\t\t\t<td" + strings.Join(attrs, " ") + ">")); err != nil {
			return
		}
		if val := cell.Val(); val != nil {
			if _, err = fmt.Fprint(w, val); err != nil {
				return
			}
		}
		_, err = w.Write([]byte("</td>\n"))
		return
	},
}

Functions

This section is empty.

Types

type Cell

type Cell interface {
	Val() any
	SetVal(any)
	Rowspan() int
	SetRowspan(int)
	Colspan() int
	SetColspan(int)
}

type CellImpl

type CellImpl struct {
	ValValue     any `json:"val,omitempty"`
	RowspanValue int `json:"rowspan,omitempty"`
	ColspanValue int `json:"colspan,omitempty"`
}

func (*CellImpl) Colspan

func (c *CellImpl) Colspan() int

func (*CellImpl) Rowspan

func (c *CellImpl) Rowspan() int

func (*CellImpl) SetColspan

func (c *CellImpl) SetColspan(i int)

func (*CellImpl) SetRowspan

func (c *CellImpl) SetRowspan(i int)

func (*CellImpl) SetVal

func (c *CellImpl) SetVal(a any)

func (*CellImpl) Val

func (c *CellImpl) Val() any

type Cells

type Cells []Cell

func (*Cells) UnmarshalJSON

func (c *Cells) UnmarshalJSON(data []byte) (err error)

type HtmlBuilder

type HtmlBuilder struct {
	Begin func(w io.Writer) (err error)
	End   func(w io.Writer) (err error)
	Row   func(w io.Writer, index int) (close func() error, err error)
	Cell  func(w io.Writer, rowIndex, cellIndex int, cell Cell, attrs []string) (err error)
}

func (*HtmlBuilder) Build

func (b *HtmlBuilder) Build(w io.Writer, rows Rows) (err error)

type Node

type Node struct {
	Depth,
	Row,
	Col int
	Children []*Node
	// contains filtered or unexported fields
}

func (*Node) Add

func (n *Node) Add(v any, cb ...func(n *Node)) *Node

func (*Node) AddChild

func (n *Node) AddChild(child ...*Node) *Node

func (*Node) BuildTree

func (n *Node) BuildTree() (tree *Tree)

func (*Node) Colspan

func (n *Node) Colspan() int

func (*Node) Rowspan

func (n *Node) Rowspan() int

func (*Node) SetColspan

func (n *Node) SetColspan(v int)

func (*Node) SetRowspan

func (n *Node) SetRowspan(v int)

func (*Node) SetVal

func (n *Node) SetVal(v any)

func (*Node) Val

func (n *Node) Val() any

type Nodes

type Nodes []*Node

func (Nodes) Sort

func (h Nodes) Sort()

type Rows

type Rows []Cells

func (*Rows) Transpose

func (rows *Rows) Transpose()

type Tree

type Tree struct {
	Rows    Rows
	NumRows int
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL