m |
m |
||
Line 5: | Line 5: | ||
;Widget XML tag: <code><com.ginstr.widgets.GnDropDown></code> | ;Widget XML tag: <code><com.ginstr.widgets.GnDropDown></code> | ||
− | + | ||
+ | <code>[[GnDropDown]]</code> provides the entry of dropdown values. | ||
<code>[[GnDropDown]]</code> has two ways of functioning. It can receive values either from local resources or from the database. When it’s connected to a database it needs to have a definition of the data. | <code>[[GnDropDown]]</code> has two ways of functioning. It can receive values either from local resources or from the database. When it’s connected to a database it needs to have a definition of the data. |
Revision as of 12:28, 29 June 2016
Contents
- 1 XML Attributes Description
- 2 Local sourceType and saving to database
- 3 Database sourceType and saving to database
- 4 gn:s_sourceType
- 5 gn:singleItemMode
- 6 gn:data_queryType
- 7 gn:textColor
- 8 gn:s_ZeroItemText
- 9 gn:s_title
- 10 gn:s_dataFilters
- 11 gn:s_sortColumn
- 12 gn:s_sortOrder
- 13 gn:textSize
- 14 gn:zeroItemEventEnabled
- 15 android:enabled
- 16 gn:s_listSelector
- 17 gn:event_afterDropdownClosed
GnDropDown
provides the entry of dropdown values.
GnDropDown
has two ways of functioning. It can receive values either from local resources or from the database. When it’s connected to a database it needs to have a definition of the data.
XML Attributes Description
Note: An attribute marked with asterisk (*) is a mandatory parameter when creating widget.
Attribute | Description |
---|---|
gn:s_sourceType *
|
Sets source for data load into dropdown |
gn:singleItemMode
|
Enables table with single row to be set as source |
gn:data_queryType
|
If queries.xml dbRequest used to populate dropdown defines query keys, this attribute can be used to sort the query result
|
gn:textColor
|
Changes color of zero item |
gn:s_ZeroItemText
|
Sets text of choice for zero item of the dropdown |
gn:s_title
|
Adds title to selection box of dropdown which is displayed after click on dropdown |
gn:s_dataFilters
|
GnDropdown supports filtering like GnListView , please read here how to use filters.
|
gn:s_sortColumn
|
Defines column from associated dbRequest used to sort dropdown data
|
gn:s_sortOrder
|
Toggles sort order between ascending & descending provided gn:s_sortColumn is defined
|
gn:textSize
|
Sets size of text in widget to defined value |
gn:zeroItemEventEnabled
|
Executes gn:act_setItemSelect actions also when first item in list
|
android:enabled
|
Used to disable GnDropdown so that user can not interact with it
|
gn:s_listSelector
|
Sets the color of selector when user clicks on row in GnListView
|
gn:event_afterDropdownClosed
|
Defines Action Set to be executed when dropdown selection window is closed. |
Local sourceType and saving to database
When GnDropDown
has sourceType="local"
, the following attributes are necessary in order to perform a correct save:
gn:data_request
dbRequest
to which data is written- (String) values =
tableName
- (String) values =
gn:data_field
- column to which data is saved
- (String) values =
column-Name
- (String) values =
gn:data_source_request
- this attribute that points to
dbRequest
is not used but it’s necessary because of ginstr launcher internals, it will be removed later. At present it’s necessary that this attribute is provided which points to somedbRequest
in queries.xml, thedbRequest
should not be used.
- i.e.
<source lang="xml"> <com.ginstr.widgets.GnDropDown gn:s_sourceType=”local” gn:data_field= “columnOne” gn:data_request=”tableName” gn:data_source_key_local=”@array/drop_values” gn:data_source_request=”unusedDbRequest” gn:act_afterLoad=”[gn:act_fill_dropdown]|[@+id/dropdown]” </source>
- The above example will populate a dropdown with local values from
“drop_values”
array and a save to the database is performed, data will be saved to table“tableName”
into“columnOne”
.
Database sourceType and saving to database
When GnDropDown
has sourceType="database"
, the following attributes are necessary for correct save:
gn:data_request
dbRequest
to which data is written- (String) values =
tableName
- (String) values =
gn:data_field
- column to which data is saved
- (String) values =
column-Name
- (String) values =
gn:data_source_field
- name of database field which will be displayed as value
- (String) values =
columnName
- (String) values =
gn:data_source_request
- name of
dbRequest
from which data is retrieved, values- (String) values =
tableName
- (String) values =
gn:s_sourceType
Sets source for data load into dropdown. If the attribute is omitted it sets database as source
(String) values = local
, database
Value | Description |
---|---|
local
|
Sets the source as array from resources (@array/resourceId )
|
database
|
Sets the source as database |
gn:singleItemMode
By default, ginstr launcher dropdown does not load data if the table that is set as source has only one row. When this attribute is set to true
then table is loaded even if one row is set.
(Boolean) values = true
, false
gn:data_queryType
If queries.xml dbRequest
used to populate dropdown defines query keys, this attribute can be used to sort the query result
(String) value = reverse
gn:textColor
Changes color of zero item
(String) value = hex color, i.e. #112233
(RGB) or with transparency #11223344
(ARGB)
gn:s_ZeroItemText
Sets text of choice for zero item of the dropdown
(String) value = hardcoded text or pointer to string resource, i.e. #@string/someStringId
gn:s_title
Adds title to selection box of dropdown which is displayed after click on dropdown
(String) value = hardcoded text or pointer to string resource, i.e. #@string/someStringId
gn:s_dataFilters
GnDropDown
supports filtering like GnListView
, please read here how to use filters.
gn:s_sortColumn
If dropdown data needs to be sorted this value must be used to define column from associated dbRequest
by which you want sorting to be executed.
i.e. If you want to sort by name and in queries.xml file dbRequest
you have fields
<dbRequest id=”someTable” name=”someTable” field=”name, surname” />
it’s necessary to set gn:s_sortColumn=”name”
Currently supported datatypes for sorting are:
DATETIME
TEXT
gn:s_sortOrder
Toggles sort order between ascending & descending provided gn:s_sortColumn
is defined
Sorting keywords by datatype:
DATETIME
“regular”
sorts from oldest to newest,“reverse”
from newest to oldestTEXT
“regular”
sorts from A-Z,“reverse”
from Z-A
gn:textSize
Sets size of text in widget to defined value.
Unit for size (sp) is obligatory.
(String) value = 12sp
... 25sp
...
gn:zeroItemEventEnabled
When attribute is set to true
, it executes gn:act_setItemSelect
actions also when first item in list gets selected, whose value is usually "Select..."
(Boolean) values = true
, false
android:enabled
Used to disable GnDropDown
so that user can not interact with it
gn:s_listSelector
Sets the color of selector when user clicks on row in GnListView
(HEX) value = #00000000
(ARGB)
gn:event_afterDropdownClosed
Action set which can be set on widget as attribute.
The value of attribute is set of actions which should be executed when dropdown selection window is closed.