From wiki.ginstr.com
Jump to: navigation, search
m
Line 3: Line 3:
 
;Inherited classes: <code>[http://developer.android.com/reference/android/view/View.html View]</code>
 
;Inherited classes: <code>[http://developer.android.com/reference/android/view/View.html View]</code>
 
;Android class type: <code>[http://developer.android.com/reference/android/widget/Spinner.html Spinner]</code>
 
;Android class type: <code>[http://developer.android.com/reference/android/widget/Spinner.html Spinner]</code>
;Child elements: <code>[http://developer.android.com/reference/android/widget/EditText.html EditText]</code>, <code>[http://developer.android.com/reference/android/widget/Button.html Button]</code>
 
 
;Widget XML tag: <code><com.ginstr.widgets.GnDropDown></code>
 
;Widget XML tag: <code><com.ginstr.widgets.GnDropDown></code>
  
 
Widget provides the entry of dropdown values.
 
Widget 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. See action for fill dropdown.
+
<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.
 +
 
 +
See [[gn:act_fill_dropdown|action for fill dropdown]].
  
 
==XML Attributes Description==
 
==XML Attributes Description==
Line 19: Line 20:
 
|-
 
|-
 
| title="Attribute" | <code>[[#gn:s_sourceType|gn:s_sourceType]]</code><span style="color:#FF0000">*</span>
 
| title="Attribute" | <code>[[#gn:s_sourceType|gn:s_sourceType]]</code><span style="color:#FF0000">*</span>
| title="Description" | Sets source for data load into dropdown. If the attribute is omitted it sets database as source
+
| title="Description" | Sets source for data load into dropdown
 
|-
 
|-
 
| title="Attribute" | <code>[[#gn:singleItemMode|gn:singleItemMode]]</code>
 
| title="Attribute" | <code>[[#gn:singleItemMode|gn:singleItemMode]]</code>
Line 25: Line 26:
 
|-
 
|-
 
| title="Attribute" | <code>[[#gn:data_queryType|gn:data_queryType]]</code>
 
| title="Attribute" | <code>[[#gn:data_queryType|gn:data_queryType]]</code>
| title="Description" | If '''queries.xml''' <code>dbRequest</code> that is used for populate dropdown defines query keys, then this attribute can be used to sort the query result
+
| title="Description" | If '''queries.xml''' <code>dbRequest</code> used to populate dropdown defines query keys, this attribute can be used to sort the query result
 
|-
 
|-
 
| title="Attribute" | <code>[[#gn:textColor|gn:textColor]]</code>
 
| title="Attribute" | <code>[[#gn:textColor|gn:textColor]]</code>
Line 40: Line 41:
 
|-
 
|-
 
| title="Attribute" | <code>[[#gn:s_sortColumn|gn:s_sortColumn]]</code>
 
| title="Attribute" | <code>[[#gn:s_sortColumn|gn:s_sortColumn]]</code>
| title="Description" | Defines column from associated dbRequest used to sort dropdown data
+
| title="Description" | Defines column from associated <code>dbRequest</code> used to sort dropdown data
 
|-
 
|-
 
| title="Attribute" | <code>[[#gn:s_sortOrder|gn:s_sortOrder]]</code>
 
| title="Attribute" | <code>[[#gn:s_sortOrder|gn:s_sortOrder]]</code>
 
| title="Description" | Toggles sort order between ascending & descending provided <code>[[gn:s_sortColumn]]</code> is defined
 
| title="Description" | Toggles sort order between ascending & descending provided <code>[[gn:s_sortColumn]]</code> is defined
 +
|-
 +
| title="Attribute" | <code>[[#gn:textSize|gn:textSize]]</code>
 +
| title="Description" | Sets size of text in widget to defined value
 
|-
 
|-
 
| title="Attribute" | <code>[[#gn:zeroItemEventEnabled|gn:zeroItemEventEnabled]]</code>
 
| title="Attribute" | <code>[[#gn:zeroItemEventEnabled|gn:zeroItemEventEnabled]]</code>
Line 61: Line 65:
 
When <code>[[GnDropDown]]</code> has <code>sourceType="local"</code>, the following attributes are necessary in order to perform a correct save:
 
When <code>[[GnDropDown]]</code> has <code>sourceType="local"</code>, the following attributes are necessary in order to perform a correct save:
  
;<code>gn:data_request</code>: dbRequest to which data is written
+
;<code>gn:data_request</code>: <code>dbRequest</code> to which data is written
 
::''(String)'' values = <code>tableName</code>
 
::''(String)'' values = <code>tableName</code>
 
;<code>gn:data_field</code>: column to which data is saved
 
;<code>gn:data_field</code>: column to which data is saved
 
::''(String)'' values = <code>column-Name</code>
 
::''(String)'' values = <code>column-Name</code>
;<code>gn:data_source_request</code>: 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 some dbRequest in [[queries.xml]], the dbRequest should not be used.
+
;<code>gn:data_source_request</code>: this attribute that points to <code>dbRequest</code> 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 some <code>dbRequest</code> in [[queries.xml]], the <code>dbRequest</code> should not be used.
  
i.e.
+
:i.e.
 
<source lang="xml">
 
<source lang="xml">
 
<com.ginstr.widgets.GnDropDown
 
<com.ginstr.widgets.GnDropDown
Line 82: Line 86:
 
==Database sourceType and saving to database==
 
==Database sourceType and saving to database==
 
When <code>[[GnDropDown]]</code> has <code>sourceType="database"</code>, the following attributes are necessary for correct save:
 
When <code>[[GnDropDown]]</code> has <code>sourceType="database"</code>, the following attributes are necessary for correct save:
;<code>gn:data_request</code>: dbRequest to which data is written
+
;<code>gn:data_request</code>: <code>dbRequest</code> to which data is written
 
::''(String)'' values = <code>tableName</code>
 
::''(String)'' values = <code>tableName</code>
 
;<code>gn:data_field</code>: column to which data is saved
 
;<code>gn:data_field</code>: column to which data is saved
Line 88: Line 92:
 
;<code>gn:data_source_field</code>: name of database field which will be displayed as value
 
;<code>gn:data_source_field</code>: name of database field which will be displayed as value
 
::''(String)'' values = <code>columnName</code>
 
::''(String)'' values = <code>columnName</code>
;<code>gn:data_source_request</code>: name of dbRequest from which data is retrieved, values
+
;<code>gn:data_source_request</code>: name of <code>dbRequest</code> from which data is retrieved, values
 
::''(String)'' values = <code>tableName</code>
 
::''(String)'' values = <code>tableName</code>
 +
 +
==gn:s_sourceType==
 +
Sets source for data load into dropdown. If the attribute is omitted it sets database as source
 +
 +
''(String)'' values = <code>local</code>, <code>database</code>
 +
 +
{| class="wikitable sortable" style="font-size: 85%; text-align: left;"
 +
|-
 +
! scope="col" | Value
 +
! scope="col" | Description
 +
|-
 +
| title="Value" | <code>local</code>
 +
| title="Description" | Sets the source as array from resources (<code>@array/resourceId</code>)
 +
|-
 +
| title="Value" | <code>database</code>
 +
| title="Description" | 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 <code>true</code> then table is loaded even if one row is set.
 +
 +
''(Boolean)'' values = <code>true</code>, <code>false</code>
 +
 +
==gn:data_queryType==
 +
If '''queries.xml''' <code>dbRequest</code> used to populate dropdown defines query keys, this attribute can be used to sort the query result
 +
 +
''(String)'' value = <code>reverse</code>
 +
 +
==gn:textColor==
 +
Changes color of zero item
 +
 +
''(String)'' value = hex color, i.e. <code>#112233</code> (RGB) or with transparency <code>#11223344</code> (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. <code>#@string/someStringId</code>
 +
 +
==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. <code>#@string/someStringId</code>
 +
 +
==gn:s_dataFilters==
 +
<code>[[GnDropdown]]</code> supports filtering like <code>[[GnListView]]</code>, please read [[GnListView#GnListView_Filtering|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 <code>dbRequest</code> by which you want sorting to be executed.
 +
 +
i.e. If you want to sort by name and in [[queries.xml]] file <code>dbRequest</code> you have fields
 +
<code><dbRequest id=”someTable” name=”someTable” field=”name, surname” /></code>
 +
it’s necessary to set <code>gn:s_sortColumn=”name”</code>
 +
 +
Currently supported datatypes for sorting are:
 +
*<code>DATETIME</code>
 +
*<code>TEXT</code>
 +
 +
==gn:s_sortOrder==
 +
Toggles sort order between ascending & descending provided <code>[[gn:s_sortColumn]]</code> is defined
 +
 +
Sorting keywords by datatype:
 +
;<code>DATETIME</code>: <code>“regular”</code> sorts from oldest to newest, <code>“reverse”</code> from newest to oldest
 +
;<code>TEXT</code>: <code>“regular”</code> sorts from A-Z, <code>“reverse”</code> from Z-A
 +
 +
==gn:textSize==
 +
Sets size of text in widget to defined value.
 +
 +
Unit for size (sp) is obligatory.
 +
 +
''(String)'' value = <code>12sp</code> ... <code>25sp</code> ...
 +
 +
==gn:zeroItemEventEnabled==
 +
When attribute is set to <code>true</code>, it executes <code>[[gn:act_setItemSelect]]</code> actions also when first item in list gets selected, whose value is usually <code>"Select..."</code>
 +
 +
''(Boolean)'' values = <code>true</code>, <code>false</code>
 +
 +
==android:enabled==
 +
Used to disable <code>[[GnDropdown]]</code> so that user can not interact with it
 +
 +
==gn:s_listSelector==
 +
Sets the color of selector when user clicks on row in <code>[[GnListView]]</code>
 +
 +
''(HEX)'' value = <code>#00000000</code> (ARGB)
 +
 +
==gn:event_afterDropdownClosed==
 +
[[Action set]] which can be set on widget as attribute.
 +
 +
The value of attribute is [[Action_Sets|set of actions]] which should be executed when dropdown selection window is closed.

Revision as of 11:35, 29 June 2016

Inherited classes
View
Android class type
Spinner
Widget XML tag
<com.ginstr.widgets.GnDropDown>

Widget 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.

See action for fill dropdown.

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
gn:data_field
column to which data is saved
(String) values = column-Name
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 some dbRequest in queries.xml, the dbRequest 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
gn:data_field
column to which data is saved
(String) values = column-Name
gn:data_source_field
name of database field which will be displayed as value
(String) values = columnName
gn:data_source_request
name of dbRequest from which data is retrieved, values
(String) values = tableName

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 oldest
TEXT
“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.