Binding complex data types
The types that we have used in our data binding exploration so far have been limited to mappings of the Go primitive types. This means that they represent simple variables with a single element. For many applications, it will be necessary to display more complex data, such as lists, maps, or even custom structs. In this section, we will look at how that can be done, starting with the DataList
type.
Using lists of data
Whether you wish to use data bindings to present data to a widget.List
or a widget.RadioGroup
, or if you are modeling your data with bindings that will be passed to your own widgets, the concept of a data list will be important. The data binding API defines DataList
as a binding that provides additional Length
and GetItem(int)
functions, as follows:
type DataList interface { DataItem GetItem(int) DataItem Length() int }
This generic definition means that a list...