grider

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2021 License: MIT Imports: 13 Imported by: 0

README

grider

Backend part of the web table view

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FieldTagLabel = "grid"

FieldTagLabel holds struct field tag key.

Functions

func SetLinkPrefix

func SetLinkPrefix(s string)

func ToSnakeCase

func ToSnakeCase(str string) string

ToSnakeCase converts string like RobertEgorov to robert_egorov.

func WitTitlePrefix

func WitTitlePrefix(prefix string) func(*Option)

func WithDownloadOption

func WithDownloadOption(b bool) func(*Option)

func WithI18n added in v0.0.2

func WithI18n() func(*Option)

Types

type Action added in v0.0.2

type Action struct {
	Code string
	Perm string
}

type Date

type Date date.Date

func (Date) ConvertToString

func (t Date) ConvertToString(layout string) string

type DownloadResponse

type DownloadResponse struct {
	FileName    string
	ContentType string
	Content     string // base64
}

type Float

type Float null.Float

func (Float) ConvertToString

func (t Float) ConvertToString(layout string) string

type Formatter

type Formatter interface {
	ConvertToString(layout string) string
}

type Grid

type Grid struct {
	Columns        []GridColumn  `json:"columns"`
	Rows           [][]string    `json:"rows"`
	Objects        []interface{} `json:"objects,omitempty"`
	IsDownloadable bool          `json:"isDownloadable"`
	Actions        [][]Action    `json:"actions,omitempty"`
	// contains filtered or unexported fields
}

func New

func New(opts ...func(*Option)) *Grid

func (*Grid) ApplySliceOfStruct

func (g *Grid) ApplySliceOfStruct(src interface{}) *Grid

ApplySliceOfStruct converts slice of any struct to Grid, slice of column and rows.

func (*Grid) DeleteColumns

func (g *Grid) DeleteColumns(col []string)

DeleteColumns deletes columns with exact names in cols.

func (*Grid) Excelize

func (r *Grid) Excelize(fname string) (*DownloadResponse, error)

func (*Grid) JSON

func (g *Grid) JSON() ([]byte, error)
func (g *Grid) ReplaceCellWithFullLinks() error

type GridColumn

type GridColumn struct {
	Name       string `json:"name"`
	Hidden     bool   `json:"hidden,omitempty"`     // default false
	Sortable   bool   `json:"sortable,omitempty"`   // default false
	Filterable bool   `json:"filterable,omitempty"` // default false
	Title      string `json:"title,omitempty"`      // default ""
	Perm       string `json:"perm,omitempty"`       // default not permission
	Type       string `json:"type,omitempty"`       // default "" (regular text)
	Href       string `json:"href,omitempty"`       // default "" (no link)
	Align      string `json:"align,omitempty"`      // default "" ("left") cell align
	Caption    string `json:"caption,omitempty"`    // default ""
	Method     string `json:"method,omitempty"`     // ?
	Icons      string `json:"icons,omitempty"`      // comma separated fa-* icon names
	IconsAlign string `json:"ialign,omitempty"`     // default "" ("left") "right" - after text
	Target     string `json:"target,omitempty"`     // default "" browser window target for opening link
}

GridColumn describes grid column's properties.

type Int

type Int null.Int

func (Int) ConvertToString

func (t Int) ConvertToString(layout string) string

type NullTime

type NullTime null.Time

func (NullTime) ConvertToString

func (t NullTime) ConvertToString(layout string) string

type Option

type Option struct {
	// contains filtered or unexported fields
}

type String

type String null.String

func (String) ConvertToString

func (t String) ConvertToString(layout string) string

type Time

type Time time.Time

func (Time) ConvertToString

func (t Time) ConvertToString(layout string) string

Jump to

Keyboard shortcuts

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