Documentation ¶
Index ¶
- Constants
- Variables
- func FieldsToString(fields []Field) []string
- func NewValue(val interface{}) *value
- func Orm(orm orm.Interface) *gridSource
- func Translations(ids ...string) []i18n.Message
- type Action
- type Claim
- type Config
- type ExportTypes
- type FeGridActive
- type FeGridFilter
- type Field
- func (f *Field) Callback() (callback interface{}, args interface{})
- func (f *Field) DatabaseId() string
- func (f Field) Description() string
- func (f Field) Error() error
- func (f *Field) Field(name string) *Field
- func (f Field) FieldType() string
- func (f *Field) Fields() []Field
- func (f Field) Id() string
- func (f Field) IsFilterable() bool
- func (f Field) IsGroupable() bool
- func (f Field) IsHidden() bool
- func (f *Field) IsPrimary() bool
- func (f Field) IsReadOnly() bool
- func (f *Field) IsRelation() bool
- func (f Field) IsRemoved() bool
- func (f Field) IsSortable() bool
- func (f Field) MarshalJSON() ([]byte, error)
- func (f *Field) Option(key string) interface{}
- func (f *Field) Options() map[string]interface{}
- func (f Field) Position() int
- func (f *Field) SetCallback(callback interface{}, args ...interface{}) *Field
- func (f *Field) SetDatabaseId(id string)
- func (f *Field) SetDescription(description interface{}) *Field
- func (f *Field) SetFieldType(fieldType string) *Field
- func (f *Field) SetFields(fields []Field)
- func (f *Field) SetFilterable(filterable bool) *Field
- func (f *Field) SetGroupable(groupable bool) *Field
- func (f *Field) SetHidden(hidden interface{}) *Field
- func (f *Field) SetId(id string) *Field
- func (f *Field) SetMode(mode int)
- func (f *Field) SetOption(key string, value interface{}) *Field
- func (f *Field) SetPosition(position interface{}) *Field
- func (f *Field) SetPrimary(primary bool)
- func (f *Field) SetReadOnly(readOnly bool) *Field
- func (f *Field) SetRelation(r bool) *Field
- func (f *Field) SetRemove(remove interface{}) *Field
- func (f *Field) SetSortable(sortable bool) *Field
- func (f *Field) SetTitle(title interface{}) *Field
- func (f *Field) SetView(view interface{}) *Field
- func (f Field) Title() string
- func (f *Field) View() string
- type Filter
- type Grid
- func (g *Grid) AddCallback(name int, fn func(*Grid) error)
- func (g *Grid) Config() *Config
- func (g *Grid) Controller() controller.Interface
- func (g *Grid) Field(name string) *Field
- func (g *Grid) Fields() []Field
- func (g *Grid) IsCallback() bool
- func (g *Grid) Mode() int
- func (g *Grid) Render()
- func (g *Grid) SetCondition(c *sqlquery.Condition) *Grid
- func (g *Grid) SetExport(exports ...string) error
- func (g *Grid) SetSource(src SourceI) error
- func (g *Grid) Source() interface{}
- type Select
- type SelectItem
- type SourceI
- type UserGrid
- type UserGridField
- type UserGridFilter
- type UserGridSort
Constants ¶
const ( ConditionFilterSeparator = ";" ConditionSeparator = "," ConditionFilterPrefix = "filter_" )
const ( CREATE = iota + 1 UPDATE DELETE CALLBACK FILTERCONFIG VTable VDetails VUpdate VCreate Export )
Grid modes
const ( BeforeFirst = iota + 1 AfterFirst BeforeAll AfterAll BeforeCreate AfterCreate BeforeUpdate AfterUpdate BeforeDelete AfterDelete )
Callbacks
const ( FeSelect = "select" FeUnique = "unique" FeDecorator = "decorator" FeNoEscaping = "noEscaping" FeReturnObject = "vueReturnObject" )
Frontend constants
const TPrefix = "GRID§§"
Variables ¶
var ErrJsonInvalid = errors.New("grid: json is invalid")
var ErrRequestBody = errors.New("grid: request body is empty")
Functions ¶
func FieldsToString ¶
func NewValue ¶
func NewValue(val interface{}) *value
NewValue creates a new *value with the given value for all element. the grid ptr is added.
func Translations ¶
Types ¶
type Action ¶
type Action struct { DisplayLeft bool `json:"l,omitempty"` DisableFilter bool `json:"disableFilter,omitempty"` DisableCreate bool `json:"disableCreate,omitempty"` DisableDetail bool `json:"disableDetail,omitempty"` DisableUpdate bool `json:"disableUpdate,omitempty"` DisableDelete bool `json:"disableDelete,omitempty"` }
Action
type Config ¶
type Config struct { // ID is used to cache the grid fields. This must be unique. ID string `json:"id,omitempty"` Title string `json:"title,omitempty"` Description string `json:"description,omitempty"` Policy int `json:"-"` Action Action `json:"action,omitempty"` // should not be able for the user to config. Filter Filter `json:"filter,omitempty"` Exports []ExportTypes `json:"exports,omitempty"` }
Config - general grid config
func (*Config) DisableCreate ¶
func (*Config) DisableDelete ¶
func (*Config) DisableDetail ¶
func (*Config) DisableFilter ¶
func (*Config) DisableUpdate ¶
type ExportTypes ¶
type FeGridActive ¶
type FeGridFilter ¶
type Field ¶
type Field struct {
// contains filtered or unexported fields
}
func (*Field) DatabaseId ¶
func (Field) Description ¶
func (*Field) Field ¶
Field will return the field by the given name. If it was not found, an error will be set.
func (Field) IsFilterable ¶
func (Field) IsGroupable ¶
func (Field) IsReadOnly ¶
func (*Field) IsRelation ¶
func (Field) IsSortable ¶
func (Field) MarshalJSON ¶
MarshalJson is used to create the header information of the field.
func (*Field) SetCallback ¶
func (*Field) SetDatabaseId ¶
func (*Field) SetDescription ¶
func (*Field) SetFieldType ¶
func (*Field) SetFilterable ¶
func (*Field) SetGroupable ¶
func (*Field) SetPosition ¶
func (*Field) SetPrimary ¶
func (*Field) SetReadOnly ¶
func (*Field) SetRelation ¶
func (*Field) SetSortable ¶
type Filter ¶
type Filter struct { List []FeGridFilter `json:"list,omitempty"` Active FeGridActive `json:"active,omitempty"` }
type Grid ¶
type Grid struct {
// contains filtered or unexported fields
}
func New ¶
func New(c controller.Interface, config *Config) *Grid
New creates a grid instance with the given controller. the controller is used to fetch all the request data and add the response.
func (*Grid) AddCallback ¶
AddCallback to the grid. (Before/After)First,All,Create,Update,Delete exists.
func (*Grid) Controller ¶
func (g *Grid) Controller() controller.Interface
Controller returns the grid controller. This data could be useful in the implemented source.
func (*Grid) Field ¶
Field by name. If the field was not found a new Field with an error is created. This helps the user to avoid annoying error if statements. If there was an error, the grid will automatically response with an error message. Or you can call field.Error() != nil to check if an error happend.
func (*Grid) IsCallback ¶
func (*Grid) Mode ¶
Mode by the given url / http method. POST = grid create PUT = grid update DELETE = grid delete GET without any mode param = grid view table GET with mode param "create" = grid view create GET with mode param "update" = grid view update GET with mode param "details" = grid view details GET with mode param "callback" = grid view callback everything else will return 0
func (*Grid) SetCondition ¶
SetCondition adds a condition on the primary source.
type SelectItem ¶
type SelectItem struct { Text interface{} `json:"text"` Value interface{} `json:"value"` }
type SourceI ¶
type SourceI interface { // Init is called right after the source was added. // This function can be used if the source has to get initialized after it was added. Init(grid *Grid) error // Fields of the grid. Fields(grid *Grid) ([]Field, error) // UpdatedFields is called before render. The grid fields have the user updated configurations. UpdatedFields(grid *Grid) error // Callback is called on a callback request of the grid. Callback(callback string, grid *Grid) (interface{}, error) // First request a single row by the given condition. First(c *sqlquery.Condition, grid *Grid) (interface{}, error) // All data by the given condition. All(c *sqlquery.Condition, grid *Grid) (interface{}, error) // Create the object Create(grid *Grid) (interface{}, error) // Update the object Update(grid *Grid) error // Delete the object by the given condition. Delete(c *sqlquery.Condition, grid *Grid) error // Count all the existing object by the given condition. Count(c *sqlquery.Condition, grid *Grid) (int, error) // Interface returns the under laying interface Interface() interface{} }
type UserGrid ¶
type UserGrid struct { orm.Model ID int GridID string UserID int Name string GroupBy orm.NullString Filters []UserGridFilter Sorting []UserGridSort Fields []UserGridField Default bool RowsPerPage orm.NullInt }