Documentation ¶
Overview ¶
Package list contains list-type controls. This includes select lists, as well hierarchical lists.
Index ¶
- Constants
- func NoSelectionItemList() []interface{}
- func SelectOneItemList() []interface{}
- func SortIds(ids []string)
- type CheckboxList
- func (l *CheckboxList) ColumnCount() int
- func (l *CheckboxList) Deserialize(dec page.Decoder)
- func (l *CheckboxList) DrawInnerHtml(_ context.Context, w io.Writer)
- func (l *CheckboxList) DrawingAttributes(ctx context.Context) html5tag.Attributes
- func (l *CheckboxList) Init(parent page.ControlI, id string)
- func (l *CheckboxList) LayoutDirection() control.LayoutDirection
- func (l *CheckboxList) RenderItem(item *Item) (h string)
- func (l *CheckboxList) RenderItems(items []*Item) string
- func (l *CheckboxList) Serialize(e page.Encoder)
- func (l *CheckboxList) SetColumnCount(columns int) CheckboxListI
- func (l *CheckboxList) SetIsScrolling(s bool) CheckboxListI
- func (l *CheckboxList) SetLabelDrawingMode(mode html5tag.LabelDrawingMode) CheckboxListI
- func (l *CheckboxList) SetLayoutDirection(direction control.LayoutDirection) CheckboxListI
- func (l *CheckboxList) SetRowClass(c string) CheckboxListI
- func (l *CheckboxList) UpdateFormValues(ctx context.Context)
- type CheckboxListCreator
- type CheckboxListI
- type IDSetter
- type IDer
- type IdSlice
- type Item
- func (i *Item) AddClass(class string) *Item
- func (i *Item) Anchor() string
- func (i *Item) AnchorAttributes() html5tag.Attributes
- func (i *Item) Attributes() html5tag.Attributes
- func (i *Item) Deserialize(dec page.Decoder)
- func (i *Item) Disabled() bool
- func (i *Item) HasAnchor() bool
- func (i *Item) HasChildItems() bool
- func (i *Item) ID() string
- func (i *Item) IntValue() int
- func (i *Item) IsDivider() bool
- func (i *Item) IsEmptyValue() bool
- func (i *Item) Label() string
- func (i *Item) RenderLabel() (h string)
- func (i *Item) Serialize(e page.Encoder)
- func (i *Item) SetAnchor(a string) *Item
- func (i *Item) SetAttribute(key, value string) *Item
- func (i *Item) SetDisabled(d bool)
- func (i *Item) SetID(id string)
- func (i *Item) SetIsDivider(d bool)
- func (i *Item) SetLabel(l string)
- func (i *Item) SetShouldEscapeLabel(e bool) *Item
- func (i *Item) SetValue(v string) *Item
- func (i *Item) Value() string
- type ItemIDer
- type ItemIntIDer
- type Labeler
- type List
- func (l *List) Add(label string, value ...string) *Item
- func (l *List) AddAt(index int, label string, value ...string)
- func (l *List) AddItemAt(index int, item *Item)
- func (l *List) AddItems(items ...interface{})
- func (l *List) Clear()
- func (l *List) Deserialize(dec page.Decoder)
- func (l *List) GetItemByID(id string) (foundItem *Item)
- func (l *List) GetItemByValue(value string) (id string, foundItem *Item)
- func (l *List) ItemAt(index int) *Item
- func (l *List) Items() []*Item
- func (l *List) Len() int
- func (l *List) RemoveAt(index int)
- func (l *List) Serialize(e page.Encoder)
- type ListI
- type ListValue
- type MultiselectList
- func (l *MultiselectList) Deserialize(dec page.Decoder)
- func (l *MultiselectList) DrawInnerHtml(_ context.Context, w io.Writer)
- func (l *MultiselectList) DrawTag(ctx context.Context, w io.Writer)
- func (l *MultiselectList) DrawingAttributes(ctx context.Context) html5tag.Attributes
- func (l *MultiselectList) Init(parent page.ControlI, id string)
- func (l *MultiselectList) IsValueSelected(v string) bool
- func (l *MultiselectList) MarshalState(m page.SavedState)
- func (l *MultiselectList) SelectedIds() []string
- func (l *MultiselectList) SelectedItems() []*Item
- func (l *MultiselectList) SelectedLabels() []string
- func (l *MultiselectList) SelectedValues() []string
- func (l *MultiselectList) Serialize(e page.Encoder)
- func (l *MultiselectList) SetData(data interface{})
- func (l *MultiselectList) SetSelectedValueNoRefresh(value string, on bool)
- func (l *MultiselectList) SetSelectedValues(values []string)
- func (l *MultiselectList) SetSelectedValuesNoRefresh(values []string)
- func (l *MultiselectList) SetSize(size int) MultiselectListI
- func (l *MultiselectList) SetValue(v interface{})
- func (l *MultiselectList) Size() int
- func (l *MultiselectList) UnmarshalState(m page.SavedState)
- func (l *MultiselectList) UpdateFormValues(ctx context.Context)
- func (l *MultiselectList) Validate(_ context.Context) bool
- func (l *MultiselectList) Value() interface{}
- type MultiselectListCreator
- type MultiselectListI
- type OrderedList
- type OrderedListCreator
- type OrderedListI
- type RadioList
- func (l *RadioList) ColumnCount() int
- func (l *RadioList) Deserialize(dec page.Decoder)
- func (l *RadioList) DrawInnerHtml(_ context.Context, w io.Writer)
- func (l *RadioList) DrawingAttributes(ctx context.Context) html5tag.Attributes
- func (l *RadioList) Init(parent page.ControlI, id string)
- func (l *RadioList) LayoutDirection() control.LayoutDirection
- func (l *RadioList) RenderItem(item *Item) (h string)
- func (l *RadioList) RenderItems(items []*Item) string
- func (l *RadioList) Serialize(e page.Encoder)
- func (l *RadioList) SetColumnCount(columns int) RadioListI
- func (l *RadioList) SetIsScrolling(s bool) RadioListI
- func (l *RadioList) SetLabelDrawingMode(mode html5tag.LabelDrawingMode) RadioListI
- func (l *RadioList) SetLayoutDirection(direction control.LayoutDirection) RadioListI
- func (l *RadioList) SetRowClass(c string) RadioListI
- func (l *RadioList) UpdateFormValues(ctx context.Context)
- type RadioListCreator
- type RadioListI
- type SelectList
- func (l *SelectList) Deserialize(dec page.Decoder)
- func (l *SelectList) DrawInnerHtml(_ context.Context, w io.Writer)
- func (l *SelectList) DrawTag(ctx context.Context, w io.Writer)
- func (l *SelectList) DrawingAttributes(ctx context.Context) html5tag.Attributes
- func (l *SelectList) Init(parent page.ControlI, id string)
- func (l *SelectList) IntValue() int
- func (l *SelectList) MarshalState(m page.SavedState)
- func (l *SelectList) SelectedItem() *Item
- func (l *SelectList) SelectedLabel() string
- func (l *SelectList) Serialize(e page.Encoder)
- func (l *SelectList) SetData(data interface{})
- func (l *SelectList) SetSelectedValue(v string)
- func (l *SelectList) SetValue(v interface{})
- func (l *SelectList) StringValue() string
- func (l *SelectList) UnmarshalState(m page.SavedState)
- func (l *SelectList) UpdateFormValues(ctx context.Context)
- func (l *SelectList) Validate(ctx context.Context) bool
- func (l *SelectList) Value() interface{}
- type SelectListCreator
- type SelectListI
- type UnorderedList
- func (l *UnorderedList) Deserialize(dec page.Decoder)
- func (l *UnorderedList) DrawInnerHtml(_ context.Context, w io.Writer)
- func (l *UnorderedList) DrawTag(ctx context.Context, w io.Writer)
- func (l *UnorderedList) DrawingAttributes(ctx context.Context) html5tag.Attributes
- func (l *UnorderedList) GetItemsHtml(items []*Item) string
- func (l *UnorderedList) Init(parent page.ControlI, id string)
- func (l *UnorderedList) ItemTag() string
- func (l *UnorderedList) Serialize(e page.Encoder)
- func (l *UnorderedList) SetBulletStyle(s string) UnorderedListI
- func (l *UnorderedList) SetData(data interface{})
- func (l *UnorderedList) SetItemTag(s string) UnorderedListI
- type UnorderedListCreator
- type UnorderedListI
- type ValueLabeler
Constants ¶
const ( OrderedListNumberTypeNumber = "1" // default OrderedListNumberTypeUpperLetter = "A" OrderedListNumberTypeLowerLetter = "a" OrderedListNumberTypeUpperRoman = "I" OrderedListNumberTypeLowerRoman = "i" )
const ( // UnorderedListStyleDisc is the default list style for main items and is a bullet UnorderedListStyleDisc = "disc" // default // UnorderedListStyleCircle is the default list style for 2nd level items and is an open circle UnorderedListStyleCircle = "circle" // UnorderedListStyleSquare sets a square as the bullet UnorderedListStyleSquare = "square" // UnorderedListStyleNone removes the bullet from the list UnorderedListStyleNone = "none" )
Variables ¶
This section is empty.
Functions ¶
func NoSelectionItemList ¶
func NoSelectionItemList() []interface{}
NoSelectionItemList returns a default item list to start a selection list that allows no selection
func SelectOneItemList ¶
func SelectOneItemList() []interface{}
SelectOneItemList returns a default item list to start a selection list that asks the user to select an item
Types ¶
type CheckboxList ¶
type CheckboxList struct { MultiselectList // contains filtered or unexported fields }
CheckboxList is a multi-select control that presents its choices as a list of checkboxes. Styling is provided by divs and spans that you can provide css for in your style sheets. The goradd.css file has default styling to handle the basics. It wraps the whole thing in a div that can be set to scroll as well, so that the final structure can be styled like a multi-column table, or a single-column scrolling list much like a standard html select list.
func GetCheckboxList ¶
func GetCheckboxList(c page.ControlI, id string) *CheckboxList
GetCheckboxList is a convenience method to return the control with the given id from the page.
func NewCheckboxList ¶
func NewCheckboxList(parent page.ControlI, id string) *CheckboxList
NewCheckboxList creates a new CheckboxList
func (*CheckboxList) ColumnCount ¶
func (l *CheckboxList) ColumnCount() int
ColumnCount returns the current column count.
func (*CheckboxList) Deserialize ¶
func (l *CheckboxList) Deserialize(dec page.Decoder)
func (*CheckboxList) DrawInnerHtml ¶
func (l *CheckboxList) DrawInnerHtml(_ context.Context, w io.Writer)
DrawInnerHtml is called by the framework to draw the contents of the list.
func (*CheckboxList) DrawingAttributes ¶
func (l *CheckboxList) DrawingAttributes(ctx context.Context) html5tag.Attributes
DrawingAttributes retrieves the tag's attributes at draw time. You should not normally need to call this, and the attributes are disposed of after drawing, so they are essentially read-only.
func (*CheckboxList) Init ¶
func (l *CheckboxList) Init(parent page.ControlI, id string)
Init is called by subclasses
func (*CheckboxList) LayoutDirection ¶
func (l *CheckboxList) LayoutDirection() control.LayoutDirection
LayoutDirection returns the direction of how items are spread across the columns.
func (*CheckboxList) RenderItem ¶
func (l *CheckboxList) RenderItem(item *Item) (h string)
RenderItem is called by the framework to render a single item in the list.
func (*CheckboxList) RenderItems ¶
func (l *CheckboxList) RenderItems(items []*Item) string
func (*CheckboxList) Serialize ¶
func (l *CheckboxList) Serialize(e page.Encoder)
func (*CheckboxList) SetColumnCount ¶
func (l *CheckboxList) SetColumnCount(columns int) CheckboxListI
SetColumnCount sets the number of columns to use to display the list. Items will be evenly distributed across the columns.
func (*CheckboxList) SetIsScrolling ¶
func (l *CheckboxList) SetIsScrolling(s bool) CheckboxListI
SetIsScrolling sets whether the list will scroll if it gets bigger than its bounding box. You will need to style the bounding box to give it limits, or else it will simply grow as big as the list.
func (*CheckboxList) SetLabelDrawingMode ¶
func (l *CheckboxList) SetLabelDrawingMode(mode html5tag.LabelDrawingMode) CheckboxListI
SetLabelDrawingMode indicates how labels for each of the checkboxes are drawn.
func (*CheckboxList) SetLayoutDirection ¶
func (l *CheckboxList) SetLayoutDirection(direction control.LayoutDirection) CheckboxListI
SetLayoutDirection specifies how items are distributed across the columns.
func (*CheckboxList) SetRowClass ¶
func (l *CheckboxList) SetRowClass(c string) CheckboxListI
SetRowClass sets the class to the div wrapper around each row. If blank, will be given a default.
func (*CheckboxList) UpdateFormValues ¶
func (l *CheckboxList) UpdateFormValues(ctx context.Context)
UpdateFormValues is used by the framework to cause the control to retrieve its values from the form
type CheckboxListCreator ¶
type CheckboxListCreator struct { ID string // Items is a static list of labels and values that will be in the list. Or, use a DataProvider to dynamically generate the items. Items []ListValue // DataProvider is the control that will dynamically provide the data for the list and that implements the DataBinder interface. DataProvider control.DataBinder // DataProviderID is the id of a control that will dynamically provide the data for the list and that implements the DataBinder interface. DataProviderID string // ColumnCount specifies how many columns to show ColumnCount int // LayoutDirection determines how the items are arranged in the columns LayoutDirection control.LayoutDirection // LabelDrawingMode specifies how the labels on the radio buttons will be associated with the buttons LabelDrawingMode html5tag.LabelDrawingMode // IsScrolling will give the inner div a vertical scroll style. You will need to style the height of the outer control to have a fixed style as well. IsScrolling bool // RowClass is the class assigned to each row RowClass string // Value is the initial value of the textbox. Often its best to load the value in a separate Load step after creating the control. Value string // SaveState saves the selected value so that it is restored if the form is returned to. SaveState bool page.ControlOptions }
func (CheckboxListCreator) Create ¶
Create is called by the framework to create a new control from the Creator. You do not normally need to call this.
func (CheckboxListCreator) Init ¶
func (c CheckboxListCreator) Init(ctx context.Context, ctrl CheckboxListI)
type CheckboxListI ¶
type CheckboxListI interface { MultiselectListI SetColumnCount(int) CheckboxListI SetLayoutDirection(direction control.LayoutDirection) CheckboxListI SetLabelDrawingMode(mode html5tag.LabelDrawingMode) CheckboxListI SetIsScrolling(s bool) CheckboxListI SetRowClass(c string) CheckboxListI RenderItems(items []*Item) string RenderItem(item *Item) string }
type IDSetter ¶
type IDSetter interface {
SetID(id string)
}
IDSetter is an interface for an item that sets an id.
type IdSlice ¶
type IdSlice []string
IdSlice is a slice of string ids, and is used to sort a list of ids that the item list uses.
type Item ¶
type Item struct { List // contains filtered or unexported fields }
An Item is an object that is a member of a list. HTML has a few different kinds of lists, and this can be a member of a select list (<select>), or an ordered or unordered list (<ul> or <ol>). It is up to the manager of the list to render the item, but this serves as a place to store options about the item. Not all options are pertinent to all lists.
A list item generally has a value, and a label. Often, lists will have ids too, that will appear in the html output, but the id values are managed by the list manager and generally should not be set by you. In situations where the user selects a list item, you would use the id to retrieve the Item selected.
func NewItem ¶
NewItem creates a new item for a list. Specify an empty string for an item that represents no selection.
func NewItemFromItemIDer ¶
NewItemFromItemIDer creates a new item from any object that has an ID and String method. Note that the ID() of the ItemIDer will become the value of the select item, and the String() will become the label
func NewItemFromItemIntIDer ¶
func NewItemFromItemIntIDer(i ItemIntIDer) *Item
func NewItemFromLabeler ¶
NewItemFromLabeler creates a new item from any object that has just a Label method.
func NewItemFromStringer ¶
NewItemFromStringer creates a new item from any object that has just a String method. The label and value will be the same.
func NewItemFromValueLabeler ¶
func NewItemFromValueLabeler(v ValueLabeler) *Item
NewItemFromValueLabeler creates a new item from any object that has a Value and Label method.
func (*Item) AnchorAttributes ¶
func (i *Item) AnchorAttributes() html5tag.Attributes
AnchorAttributes returns the attributes that will be used for each of the anchor tags.
You can directly set attributes on the returned value.
func (*Item) Attributes ¶
func (i *Item) Attributes() html5tag.Attributes
Attributes returns a pointer to the attributes of the item for customization. You can directly set the attributes on the returned object.
func (*Item) Deserialize ¶
func (*Item) HasChildItems ¶
func (*Item) IsEmptyValue ¶
IsEmptyValue returns true if the value is empty, meaning it does not satisfy a selection being made if the list has IsRequired turned on.
func (*Item) RenderLabel ¶
RenderLabel is called by list implementations to render the item.
func (*Item) SetAnchor ¶
SetAnchor assigns the value of the href attribute. This will cause the item to output with an anchor tag (a).
func (*Item) SetAttribute ¶
func (*Item) SetDisabled ¶
func (*Item) SetID ¶
SetID should not be called by your code typically. It is exported for implementations of item lists. The IDs of an item list are completely managed by the list, you cannot have custom ids.
func (*Item) SetIsDivider ¶
func (*Item) SetShouldEscapeLabel ¶
type ItemIntIDer ¶
ItemIntIDer matches orm objects that use an int type for the id
type List ¶
type List struct {
// contains filtered or unexported fields
}
List manages a list of *Item items. List is designed to be embedded in another structure, and will turn that object into a manager of list items. List will manage the id's of the items in its list, you do not have control of that, and it needs to manage those ids in order to efficiently manage the selection process.
Controls that embed this must implement the Serialize and Deserialize methods to call both the ControlBase's Serialize and Deserialize methods, and the ones here.
func NewList ¶
NewList creates a new item list. "owner" is the object that has the list embedded in it, and must be an IDer.
func (*List) Add ¶
Add adds the given item to the end of the list. The value is optional, but should only be one or zero values.
func (*List) AddAt ¶
AddAt adds the item at the given index. If the index is negative, it counts from the end. -1 would therefore put the item before the last item. If the index is bigger or equal to the number of items, it adds it to the end. If the index is zero, or is negative and smaller than the negative value of the number of items, it adds to the beginning. This can be an expensive operation in a long hierarchical list, so use sparingly.
func (*List) AddItemAt ¶
AddItemAt adds the item at the given index. If the index is negative, it counts from the end. If the index is -1 or bigger than the number of items, it adds it to the end. If the index is zero, or is negative and smaller than the negative value of the number of items, it adds to the beginning. This can be an expensive operation in a long hierarchical list, so use sparingly.
func (*List) AddItems ¶
func (l *List) AddItems(items ...interface{})
AddItems adds one or more objects to the end of the list. items should be a list of *Item, ValueLabeler, ItemIDer, Labeler or Stringer types. This function can accept one or more lists of items, or single items
func (*List) Deserialize ¶
func (*List) GetItemByID ¶
GetItemByID recursively searches for and returns the item corresponding to the given id. Since we are managing the id numbers, we can efficiently find the item. Note that if you add items to the list, the ids may change.
func (*List) GetItemByValue ¶
GetItemByValue recursively searches the list to find the item with the given value. It starts with the current list, and if not found, will search in sublists.
func (*List) Items ¶
Items returns a slice of the *Item items, in the order they were added or arranged.
func (*List) Len ¶
Len returns the length of the item list at the current level. In other words, it does not count items in sublists.
type ListI ¶
type ListI interface { Add(label string, value ...string) *Item AddAt(index int, label string, value ...string) AddItemAt(index int, item *Item) AddItems(items ...interface{}) ItemAt(index int) *Item Items() []*Item Clear() RemoveAt(index int) Len() int GetItemByID(id string) (foundItem *Item) GetItemByValue(value string) (id string, foundItem *Item) // contains filtered or unexported methods }
ListI is the interface for all controls that display a list of Items.
type ListValue ¶
type ListValue struct { L string // V is the value V interface{} }
ListValue is a helper for initializing a control based on List. It satisfies the ValueLabeler interface. To use it, create a slice of ListValue's and pass the list to AddItems or SetData.
type MultiselectList ¶
type MultiselectList struct { page.ControlBase List control2.DataManager // contains filtered or unexported fields }
MultiselectList is a generic list box which allows multiple selections. It is here for completeness, but is not used very often since it doesn't present an intuitive interface and is very browser dependent on what is presented. A CheckboxList is better.
func GetMultiselectList ¶
func GetMultiselectList(c page.ControlI, id string) *MultiselectList
GetMultiselectList is a convenience method to return the control with the given id from the page.
func NewMultiselectList ¶
func NewMultiselectList(parent page.ControlI, id string) *MultiselectList
func (*MultiselectList) Deserialize ¶
func (l *MultiselectList) Deserialize(dec page.Decoder)
func (*MultiselectList) DrawInnerHtml ¶
func (l *MultiselectList) DrawInnerHtml(_ context.Context, w io.Writer)
func (*MultiselectList) DrawTag ¶
func (l *MultiselectList) DrawTag(ctx context.Context, w io.Writer)
func (*MultiselectList) DrawingAttributes ¶
func (l *MultiselectList) DrawingAttributes(ctx context.Context) html5tag.Attributes
DrawingAttributes retrieves the tag's attributes at draw time. You should not normally need to call this, and the attributes are disposed of after drawing, so they are essentially read-only.
func (*MultiselectList) IsValueSelected ¶
func (l *MultiselectList) IsValueSelected(v string) bool
func (*MultiselectList) MarshalState ¶
func (l *MultiselectList) MarshalState(m page.SavedState)
MarshalState is an internal function to save the state of the control
func (*MultiselectList) SelectedIds ¶
func (l *MultiselectList) SelectedIds() []string
SelectedIds returns a list of ids sorted by id number that correspond to the selection
func (*MultiselectList) SelectedItems ¶
func (l *MultiselectList) SelectedItems() []*Item
func (*MultiselectList) SelectedLabels ¶
func (l *MultiselectList) SelectedLabels() []string
func (*MultiselectList) SelectedValues ¶
func (l *MultiselectList) SelectedValues() []string
func (*MultiselectList) Serialize ¶
func (l *MultiselectList) Serialize(e page.Encoder)
func (*MultiselectList) SetData ¶
func (l *MultiselectList) SetData(data interface{})
SetData overrides the default data setter to add objects to the item list. The result is kept in memory currently. ValueLabeler, ItemIDer, Labeler or Stringer types. This function can accept one or more lists of items, or single items.
func (*MultiselectList) SetSelectedValueNoRefresh ¶
func (l *MultiselectList) SetSelectedValueNoRefresh(value string, on bool)
func (*MultiselectList) SetSelectedValues ¶
func (l *MultiselectList) SetSelectedValues(values []string)
SetSelectedValues sets the current selection to the given values. You must ensure that the items with the values exist, it will not attempt to make sure the items exist.
func (*MultiselectList) SetSelectedValuesNoRefresh ¶
func (l *MultiselectList) SetSelectedValuesNoRefresh(values []string)
func (*MultiselectList) SetSize ¶
func (l *MultiselectList) SetSize(size int) MultiselectListI
func (*MultiselectList) SetValue ¶
func (l *MultiselectList) SetValue(v interface{})
SetValue implements the Valuer interface for general purpose value getting and setting
func (*MultiselectList) Size ¶
func (l *MultiselectList) Size() int
func (*MultiselectList) UnmarshalState ¶
func (l *MultiselectList) UnmarshalState(m page.SavedState)
UnmarshalState is an internal function to restore the state of the control
func (*MultiselectList) UpdateFormValues ¶
func (l *MultiselectList) UpdateFormValues(ctx context.Context)
UpdateFormValues is used by the framework to cause the control to retrieve its values from the form
func (*MultiselectList) Value ¶
func (l *MultiselectList) Value() interface{}
Value implements the Valuer interface for general purpose value getting and setting
type MultiselectListCreator ¶
type MultiselectListCreator struct { ID string // Items is a static list of labels and values that will be in the list. Or, use a DataProvider to dynamically generate the items. Items []ListValue // DataProvider is the control that will dynamically provide the data for the list and that implements the DataBinder interface. DataProvider control2.DataBinder // DataProviderID is the id of a control that will dynamically provide the data for the list and that implements the DataBinder interface. DataProviderID string // Size specifies how many items to show, and turns the list into a scrolling list Size int // SaveState saves the selected value so that it is restored if the form is returned to. SaveState bool page.ControlOptions }
type MultiselectListI ¶
type MultiselectListI interface { page.ControlI ListI control2.DataManagerI }
type OrderedList ¶
type OrderedList struct {
UnorderedList
}
OrderedList is a dynamically generated html ordered list (ol). Such lists are often used as the basis for javascript and css widgets. If you use a data provider to set the data, you should call AddItems to the list in your LoadData function.
func GetOrderedList ¶
func GetOrderedList(c page.ControlI, id string) *OrderedList
GetOrderedList is a convenience method to return the control with the given id from the page.
func NewOrderedList ¶
func NewOrderedList(parent page.ControlI, id string) *OrderedList
NewOrderedList creates a new ordered list (ol tag).
func (*OrderedList) DrawInnerHtml ¶
func (l *OrderedList) DrawInnerHtml(_ context.Context, w io.Writer)
func (*OrderedList) NumberType ¶
func (l *OrderedList) NumberType() string
NumberType returns the string used for the type attribute.
func (*OrderedList) SetNumberType ¶
func (l *OrderedList) SetNumberType(t string) OrderedListI
SetNumberType sets the top level number style for the list. Choose from the OrderedListNumberType* constants. To set a number type for a sublevel, set the "type" attribute on the list item that is the parent of the sub list.
func (*OrderedList) SetStart ¶
func (l *OrderedList) SetStart(start int) OrderedListI
SetStart sets the starting number for the numbers in the top level list. To set the start of a sub-list, set the "start" attribute on the list item that is the parent of the sub-list.
type OrderedListCreator ¶
type OrderedListCreator struct { ID string // Items is a static list of labels and values that will be in the list. Or, use a DataProvider to dynamically generate the items. Items []ListValue // DataProvider is the control that will dynamically provide the data for the list and that implements the DataBinder interface. DataProvider control.DataBinder // DataProviderID is the id of a control that will dynamically provide the data for the list and that implements the DataBinder interface. DataProviderID string // NumberType is the type attribute and defaults to OrderedListNumberTypeNumber. NumberType string // StartAt sets the number to start counting from. The default is 1. StartAt int page.ControlOptions }
func (OrderedListCreator) Create ¶
Create is called by the framework to create a new control from the Creator. You do not normally need to call this.
func (OrderedListCreator) Init ¶
func (c OrderedListCreator) Init(ctx context.Context, ctrl OrderedListI)
type OrderedListI ¶
type OrderedListI interface { UnorderedListI SetNumberType(t string) OrderedListI SetStart(start int) OrderedListI }
type RadioList ¶
type RadioList struct { SelectList // contains filtered or unexported fields }
RadioList is a single-select control that presents its choices as a list of radio buttons. Styling is provided by divs and spans that you can provide css for in your style sheets. The goradd.css file has default styling to handle the basics. It wraps the whole thing in a div that can be set to scroll as well, so that the final structure can be styled like a multi-column table, or a single-table scrolling list much like a standard html select list.
func GetRadioList ¶
GetRadioList is a convenience method to return the control with the given id from the page.
func NewRadioList ¶
NewRadioList creates a new RadioList control.
func (*RadioList) ColumnCount ¶
ColumnCount returns the current column count.
func (*RadioList) Deserialize ¶
func (*RadioList) DrawInnerHtml ¶
DrawInnerHtml is called by the framework to draw the contents of the list.
func (*RadioList) DrawingAttributes ¶
func (l *RadioList) DrawingAttributes(ctx context.Context) html5tag.Attributes
DrawingAttributes retrieves the tag's attributes at draw time. You should not normally need to call this, and the attributes are disposed of after drawing, so they are essentially read-only.
func (*RadioList) LayoutDirection ¶
func (l *RadioList) LayoutDirection() control.LayoutDirection
LayoutDirection returns the direction of how items are spread across the columns.
func (*RadioList) RenderItem ¶
RenderItem is called by the framework to render a single item in the list.
func (*RadioList) RenderItems ¶
func (*RadioList) SetColumnCount ¶
func (l *RadioList) SetColumnCount(columns int) RadioListI
SetColumnCount sets the number of columns to use to display the list. Items will be evenly distributed across the columns.
func (*RadioList) SetIsScrolling ¶
func (l *RadioList) SetIsScrolling(s bool) RadioListI
SetIsScrolling sets whether the list will scroll if it gets bigger than its bounding box. You will need to style the bounding box to give it limits, or else it will simply grow as big as the list.
func (*RadioList) SetLabelDrawingMode ¶
func (l *RadioList) SetLabelDrawingMode(mode html5tag.LabelDrawingMode) RadioListI
SetLabelDrawingMode indicates how labels for each of the checkboxes are drawn.
func (*RadioList) SetLayoutDirection ¶
func (l *RadioList) SetLayoutDirection(direction control.LayoutDirection) RadioListI
SetLayoutDirection specifies how items are distributed across the columns.
func (*RadioList) SetRowClass ¶
func (l *RadioList) SetRowClass(c string) RadioListI
SetRowClass sets the class to the div wrapper around each row. If blank, will be given a default.
func (*RadioList) UpdateFormValues ¶
UpdateFormValues is used by the framework to cause the control to retrieve its values from the form
type RadioListCreator ¶
type RadioListCreator struct { ID string // Items is a static list of labels and values that will be in the list. Or, use a DataProvider to dynamically generate the items. Items []ListValue // DataProvider is the control that will dynamically provide the data for the list and that implements the DataBinder interface. DataProvider control.DataBinder // DataProviderID is the id of a control that will dynamically provide the data for the list and that implements the DataBinder interface. DataProviderID string // ColumnCount specifies how many columns to show ColumnCount int // LayoutDirection determines how the items are arranged in the columns LayoutDirection control.LayoutDirection // LabelDrawingMode specifies how the labels on the radio buttons will be associated with the buttons LabelDrawingMode html5tag.LabelDrawingMode // IsScrolling will give the inner div a vertical scroll style. You will need to style the height of the outer control to have a fixed style as well. IsScrolling bool // RowClass is the class assigned to each row RowClass string // Value is the initial value of the textbox. Often its best to load the value in a separate Load step after creating the control. Value string // OnChange is the action to take when any of the radio buttons in the list change OnChange action.ActionI // SaveState saves the selected value so that it is restored if the form is returned to. SaveState bool page.ControlOptions }
func (RadioListCreator) Create ¶
Create is called by the framework to create a new control from the Creator. You do not normally need to call this.
func (RadioListCreator) Init ¶
func (c RadioListCreator) Init(ctx context.Context, ctrl RadioListI)
type RadioListI ¶
type RadioListI interface { SelectListI SetColumnCount(int) RadioListI SetLayoutDirection(direction control.LayoutDirection) RadioListI SetLabelDrawingMode(mode html5tag.LabelDrawingMode) RadioListI SetIsScrolling(s bool) RadioListI SetRowClass(c string) RadioListI RenderItems(items []*Item) string RenderItem(item *Item) string }
type SelectList ¶
type SelectList struct { page.ControlBase List control2.DataManager // contains filtered or unexported fields }
SelectList is typically a dropdown list with a single selection. Items are selected by id number, and the SelectList completely controls the ids in the list. Create the list by calling Add or AddItems to add *Item objects. Or, use the embedded DataManager to load items. Set the size attribute if you want to display it as a scrolling list rather than a dropdown list.
func GetSelectList ¶
func GetSelectList(c page.ControlI, id string) *SelectList
GetSelectList is a convenience method to return the control with the given id from the page.
func NewSelectList ¶
func NewSelectList(parent page.ControlI, id string) *SelectList
NewSelectList creates a new select list
func (*SelectList) Deserialize ¶
func (l *SelectList) Deserialize(dec page.Decoder)
func (*SelectList) DrawInnerHtml ¶
func (l *SelectList) DrawInnerHtml(_ context.Context, w io.Writer)
DrawInnerHtml is called by the framework during drawing of the control to draw the inner html of the control
func (*SelectList) DrawingAttributes ¶
func (l *SelectList) DrawingAttributes(ctx context.Context) html5tag.Attributes
DrawingAttributes retrieves the tag's attributes at draw time. You should not normally need to call this, and the attributes are disposed of after drawing, so they are essentially read-only.
func (*SelectList) Init ¶
func (l *SelectList) Init(parent page.ControlI, id string)
Init is called by subclasses.
func (*SelectList) IntValue ¶
func (l *SelectList) IntValue() int
IntValue returns the select value as an integer.
func (*SelectList) MarshalState ¶
func (l *SelectList) MarshalState(m page.SavedState)
MarshalState is an internal function to save the state of the control
func (*SelectList) SelectedItem ¶
func (l *SelectList) SelectedItem() *Item
SelectedItem will return the currently selected item. If no item has been selected, it will return the first item in the list, since that is what will be showing in the selection list, and will update its internal pointer to make the first item the current selection.
func (*SelectList) SelectedLabel ¶
func (l *SelectList) SelectedLabel() string
SelectedLabel returns the label of the selected item
func (*SelectList) Serialize ¶
func (l *SelectList) Serialize(e page.Encoder)
func (*SelectList) SetData ¶
func (l *SelectList) SetData(data interface{})
SetData overrides the default data setter to add objects to the item list. The result is kept in memory currently. ValueLabeler, ItemIDer, Labeler or Stringer types. This function can accept one or more lists of items, or single items.
func (*SelectList) SetSelectedValue ¶
func (l *SelectList) SetSelectedValue(v string)
SetSelectedValue sets the current selection to the given id.
If you are using a DataProvider, you must make sure that the value will exist in the list. Otherwise it will compare against the current item list and panic if the item does not exist.
func (*SelectList) SetValue ¶
func (l *SelectList) SetValue(v interface{})
SetValue implements the Valuer interface for general purpose value getting and setting
func (*SelectList) StringValue ¶
func (l *SelectList) StringValue() string
StringValue returns the selected value as a string
func (*SelectList) UnmarshalState ¶
func (l *SelectList) UnmarshalState(m page.SavedState)
UnmarshalState is an internal function to restore the state of the control
func (*SelectList) UpdateFormValues ¶
func (l *SelectList) UpdateFormValues(ctx context.Context)
UpdateFormValues is used by the framework to cause the control to retrieve its values from the form
func (*SelectList) Validate ¶
func (l *SelectList) Validate(ctx context.Context) bool
Validate is called by the framework to validate the contents of the control. For a SelectList, this is typically just checking to see if something was selected if a selection is required.
func (*SelectList) Value ¶
func (l *SelectList) Value() interface{}
Value implements the Valuer interface for general purpose value getting and setting
type SelectListCreator ¶
type SelectListCreator struct { ID string // Items is a static list of labels and values that will be in the list. Or, use a DataProvider to dynamically generate the items. Items []ListValue // NilItem is a helper to add an item at the top of the list with a nil value. This is often // used to specify no selection, or a message that a selection is required. NilItem string // DataProvider is the control that will dynamically provide the data for the list and that implements the DataBinder interface. DataProvider control2.DataBinder // DataProviderID is the id of a control that will dynamically provide the data for the list and that implements the DataBinder interface. DataProviderID string // Size specifies how many items to show, and turns the list into a scrolling list Size int // Value is the initial value of the list. Often its best to load the value in a separate Load step after creating the control. Value string // OnChange is an action to take when the user changes what is selected (as in, when the javascript change event fires). OnChange action.ActionI // SaveState saves the selected value so that it is restored if the form is returned to. SaveState bool page.ControlOptions }
func (SelectListCreator) Init ¶
func (c SelectListCreator) Init(ctx context.Context, ctrl SelectListI)
type SelectListI ¶
type SelectListI interface { page.ControlI ListI control2.DataManagerI SetValue(v interface{}) Value() interface{} IntValue() int }
func GetSelectListI ¶
func GetSelectListI(c page.ControlI, id string) SelectListI
type UnorderedList ¶
type UnorderedList struct { page.ControlBase List control2.DataManager // contains filtered or unexported fields }
UnorderedList is a dynamically generated html unordered list (ul). Such lists are often used as the basis for javascript and css widgets. If you use a data provider to set the data, you should call AddItems to the list in your LoadData function.
func GetUnorderedList ¶
func GetUnorderedList(c page.ControlI, id string) *UnorderedList
GetUnorderedList is a convenience method to return the control with the given id from the page.
func NewUnorderedList ¶
func NewUnorderedList(parent page.ControlI, id string) *UnorderedList
NewUnorderedList creates a new ul type list.
func (*UnorderedList) Deserialize ¶
func (l *UnorderedList) Deserialize(dec page.Decoder)
func (*UnorderedList) DrawInnerHtml ¶
func (l *UnorderedList) DrawInnerHtml(_ context.Context, w io.Writer)
DrawInnerHtml is called by the framework to draw the content of the tag.
func (*UnorderedList) DrawingAttributes ¶
func (l *UnorderedList) DrawingAttributes(ctx context.Context) html5tag.Attributes
DrawingAttributes retrieves the tag's attributes at draw time. You should not normally need to call this, and the attributes are disposed of after drawing, so they are essentially read-only.
func (*UnorderedList) GetItemsHtml ¶
func (l *UnorderedList) GetItemsHtml(items []*Item) string
GetItemsHtml returns the HTML for the items. It is exported so that it can be overridden by other implementations of an UnorderedList.
func (*UnorderedList) ItemTag ¶
func (l *UnorderedList) ItemTag() string
ItemTag returns the HTML tag for an item in the list.
func (*UnorderedList) Serialize ¶
func (l *UnorderedList) Serialize(e page.Encoder)
func (*UnorderedList) SetBulletStyle ¶
func (l *UnorderedList) SetBulletStyle(s string) UnorderedListI
SetBulletStyle sets the list-style-type attribute of the list. Choose from the UnorderedListStyle* constants.
func (*UnorderedList) SetData ¶
func (l *UnorderedList) SetData(data interface{})
SetData replaces the current list with the given data. ValueLabeler, ItemIDer, Labeler or Stringer types are accepted. This function can accept one or more lists of items, or single items. They will all get added to the top level of the list. To add sub items, get a list item and add items to it.
func (*UnorderedList) SetItemTag ¶
func (l *UnorderedList) SetItemTag(s string) UnorderedListI
SetItemTag sets the tag that will be used for items in the list. By default this is "li".
type UnorderedListCreator ¶
type UnorderedListCreator struct { ID string // Items is a static list of labels and values that will be in the list. Or, use a DataProvider to dynamically generate the items. Items []ListValue // DataProvider is the control that will dynamically provide the data for the list and that implements the DataBinder interface. DataProvider control2.DataBinder // DataProviderID is the id of a control that will dynamically provide the data for the list and that implements the DataBinder interface. DataProviderID string // BulletStyle is the list-style-type property. BulletStyle string page.ControlOptions }
UnorderedListCreator is a declarative helper to create an UnorderedListControl. Pass it to control.AddControls() to add the declared list to the control.
func (UnorderedListCreator) Create ¶
Create is called by the framework to create a new control from the Creator. You do not normally need to call this.
func (UnorderedListCreator) Init ¶
func (c UnorderedListCreator) Init(ctx context.Context, ctrl UnorderedListI)
type UnorderedListI ¶
type UnorderedListI interface { page.ControlI ListI control2.DataManagerI GetItemsHtml(items []*Item) string SetBulletStyle(s string) UnorderedListI SetItemTag(s string) UnorderedListI ItemTag() string }
type ValueLabeler ¶
type ValueLabeler interface { Value() interface{} Label() string }