data_table

package
v0.0.0-...-7cd10a6 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2016 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ORDER_DESC      = DataTableOrder("desc")
	ORDER_ASC       = DataTableOrder("asc")
	ORDER_UNDEFINED = DataTableOrder("")
)

Variables

This section is empty.

Functions

func DataStoreHandler

func DataStoreHandler(tableStore TableStore) func(http.ResponseWriter, *http.Request, httprouter.Params)

func DefaultStoreHandler

func DefaultStoreHandler(queryFunc func(*DefaultStore) *DefaultStore) func(http.ResponseWriter, *http.Request, httprouter.Params)

func ParseKey

func ParseKey(key string) []string

func TreePostFormValues

func TreePostFormValues(values url.Values) map[string]interface{}

Types

type ColumnDefinition

type ColumnDefinition struct {
	Name       string            `json:"data"`
	Searchable bool              `json:"searchable"`
	Orderable  bool              `json:"orderable"`
	Order      DataTableOrder    `json:"-"`
	Search     *SearchDefinition `json:"search"`
}

type DataTableOrder

type DataTableOrder string

type DefaultStore

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

func (*DefaultStore) AddRow

func (ds *DefaultStore) AddRow(data *TableRow) error

func (*DefaultStore) CreateRow

func (ds *DefaultStore) CreateRow(data map[string]interface{}) *TableRow

func (*DefaultStore) FilterRow

func (ds *DefaultStore) FilterRow(row *TableRow, filter *SearchDefinition, rowSet RowSet) bool

func (*DefaultStore) GetData

func (ds *DefaultStore) GetData() RowSet

func (*DefaultStore) QueryData

func (ds *DefaultStore) QueryData(sr *SearchRequest) *TableResult

type RowSet

type RowSet interface {
	GetRows() []*TableRow
	ColumnByName(string) *ColumnDefinition
	Add(*TableRow) error
}

type SearchDefinition

type SearchDefinition struct {
	Value  string `json:"value"`
	Regexp bool   `json:"regexp"`

	InvalidRegExp bool `json:"-"`
	// contains filtered or unexported fields
}

func (*SearchDefinition) IsApplicable

func (sd *SearchDefinition) IsApplicable() bool

func (*SearchDefinition) IsMatch

func (sd *SearchDefinition) IsMatch(value string) bool

type SearchRequest

type SearchRequest struct {
	Draw    int                 `json:"draw"`
	Columns []*ColumnDefinition `json:"columns"`
	Start   int                 `json:"start"`
	Length  int                 `json:"length"`
	Search  *SearchDefinition   `json:"search"`
}

func (*SearchRequest) End

func (sr *SearchRequest) End() int

type SortableRowSet

type SortableRowSet struct {
	Limit uint
	Start uint

	Rows *rbtree.Rbtree
	// contains filtered or unexported fields
}

func (*SortableRowSet) Add

func (rs *SortableRowSet) Add(row *TableRow) error

func (*SortableRowSet) ColumnByName

func (rs *SortableRowSet) ColumnByName(name string) *ColumnDefinition

func (*SortableRowSet) GetRows

func (rs *SortableRowSet) GetRows() []*TableRow

func (*SortableRowSet) IsLess

func (rs *SortableRowSet) IsLess(origin *TableRow, than *TableRow) bool

func (*SortableRowSet) MarshalJSON

func (rs *SortableRowSet) MarshalJSON() ([]byte, error)

type TableResult

type TableResult struct {
	Draw     int         `json:"draw"`
	Total    int         `json:"recordsTotal"`
	Filtered int         `json:"recordsFiltered"`
	Data     []*TableRow `json:"data"`
	// contains filtered or unexported fields
}

type TableRow

type TableRow struct {
	Data     map[string]interface{}
	RowId    string
	RowClass string
	RowData  map[string]string
	RowAttr  map[string]string
	IsLess   func(*TableRow, *TableRow) bool
}

func (*TableRow) Less

func (r *TableRow) Less(than rbtree.Item) bool

func (*TableRow) MarshalJSON

func (tr *TableRow) MarshalJSON() ([]byte, error)

type TableStore

type TableStore interface {
	QueryData(*SearchRequest) *TableResult
}

Jump to

Keyboard shortcuts

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