Revision as of 22:53, 28 June 2016 by Mark (talk | contribs) (Created page with "<div style="float:right; clear:both; margin-left:0.5em;">__TOC__</div> Category:Widget_Library ;Inherited classes: <code>[")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Inherited classes
Android class type
Child elements
EditText, Button
Widget XML tag

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. If the attribute is omitted it sets database as source
gn:singleItemMode Enables table with single row to be set as source
gn:data_queryType If queries.xml dbRequest that is used for populate dropdown defines query keys, then 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: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 local sourceType the following attributes are necessary in order to perform a correct save.

dbRequest to which data is written
(String) values = tableName
column to which data is saved
(String) values = column-Name
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.

dbRequest to which data is written
(String) values = tableName
column to which data is saved
(String) values = column-Name
name of database field which will be displayed as value
(String) values = columnName
name of dbRequest from which data is retrieved, values
(String) values = tableName