From wiki.ginstr.com
Jump to: navigation, search

Dependent dropdowns

Widget generates a series of dropdowns which are related by a reference. By default 2 dropdowns are created. Dropdowns data source is database. Data can be defined for dropdowns in GBAM and autoimported when app is generated.

Widget id, ${gbamID}:

dropdownDependent

Back to GBAM widgets table

Datatypes

Value is stored from widget to database as text datatype.

Predefined user data

PreLoaded

First dropdown

Properties panel

User will configure this data in properties panels of selected widget:

GENERAL
VALIDATIONS
    <columnText required="true|false"></columnText>
ACTION
  • "dropdown items", ${dropdownItemsList} = ${<item>${dropdownListItem}</item>} - repeats to how many dropdown items were entered by user
  • ${dropdownListItem} - single "dropdown items" item entered by user

Dependent dropdowns

Properties panel

User will configure this data in properties panels of selected widget:

GENERAL
VALIDATIONS
ACTION
  • "select value from previous dropdown", ${dropdownItemsList} - UI dropdown which loads list of values from parent dropdown. Value must be selected in order to add values to current dropdown. If a value is deleted in parent dropdown, related values are deleted from all child dropdowns.
  • "dropdown items", ${dependantDropdownItemsList} = ${<item>${dropdownListItem}</item>} - repeats to how many dropdown items were entered by user
  • ${dropdownListItem} - single "dropdown items" item entered by user
ACTION MESSAGES
  • "no data", if $defaultApp resource ${$dropDownNoData}, if we override then it has to be formed {@string/${widgetID}NoData} - message which appears when user clicks on dropdown and no data is loaded into dropdown
  • "no selection text", if $defaultApp resource ${$dropDownZeroItem}, if we override then it has to be formed ${@string/${widgetID}ZeroItem} - text which appears when dropdown is initially loaded and nothing is selected in it
DATABASE
  • "is part of database", checkbox option by default is set as checked. When checked database column is created for this widget.
  • "additional ginstr web column settings":
  • "align text", radio button options with values: "left", "middle", "right", add to configuration.xml:
<columnText>
    <horizontalAlignment>left|center|right</horizontalAlignment>
</columnText>
  • "list of allowed values" array with list of allowed values, add to configuration.xml:
<columnText>
  <valuesList>
    <value>val1</value>
    <value>val2</value>
  </valuesList>
</columnText>
  • "pattern", add to configuration.xml:
<columnText>
    <pattern errorMessage="invalidTextTableValue">[0-9A-Z]{3}</pattern>
</columnText>
  • "related unique columns", add to configuration.xml:
<columnText>
    <uniqueInsideList>
        <reference>
          <table>refTableId1</table>
          <column>refColumnField1</column>
        </reference>
        <reference>
          <table>refTableId2</table>
          <column>refColumnField2</column>
        </reference>
    </uniqueInsideList>
</columnText>

Code snippets

GBAM Code Variables

Variables which are used in code snippet below but not defined in user modifiable inputs.

Common widget code


<com.ginstr.widgets.GnTextView        
	android:id="@+id/${widgetID}_label"
	android:layout_width="match_parent"
	android:layout_height="wrap_content"
	android:text="@string/${widgetID}"
	gn:style="@style/dropdownDatabaseText_label" />

<com.ginstr.widgets.GnDropDown
	android:id="@+id/${widgetID}_input"
	android:layout_width="match_parent"
	android:layout_height="wrap_content"
	gn:s_ZeroItemText="@string/${$dropDownZeroItem}"
	gn:msg_nodata="@string/${$dropDownNoData}" 
	gn:s_sourceType="database"
        gn:dataType="text"
	gn:act_beforeLoad="[gn:act_rawQueryToWidgets]|[${widgetID},${widgetID}_input;@+id/${widgetID};@+id/${widgetID}_input]"
        gn:act_setItemSelect="
            [gn:act_cleanWidgets]|[${listOfDependentDropdowns}],
            [gn:act_rawQueryToWidgets]|[${widgetIdDpendent},${widgetIdDpendent}_input;@+id/${widgetIdDpendent};@+id/${widgetID}_input]"
	gn:style="@style/dropdownDatabaseText_input"/>

<com.ginstr.widgets.GnTextView        
	android:id="@+id/${widgetIdDpendent}_label"
	android:layout_width="match_parent"
	android:layout_height="wrap_content"
	android:text="@string/${widgetID}"
	gn:style="@style/dropdownDatabaseText_label" />

<com.ginstr.widgets.GnDropDown
	android:id="@+id/${widgetIdDpendent}_input"
	android:layout_width="match_parent"
	android:layout_height="wrap_content"
	gn:s_ZeroItemText="@string/${$dropDownZeroItem}"
	gn:msg_nodata="@string/${$dropDownNoData}" 
	gn:s_sourceType="database"
        gn:dataType="text"
	gn:style="@style/dropdownDatabaseText_input"/>

strings.xml

Lines to be added for each language.

<string name="${widgetID}">${widgetLabel}</string>
<string name="${widgetIdDependent}">${widgetLabel}</string>
<string name="${widgetID}_table">${widgetLabel}</string>
<string name="${widgetID}_column">${widgetLabel}</string>

queries.xml

Add to queries.xml :

    <query
        id="${widgetID}_input" 
        columns="${screenLabelGenerated}_${widgetLabelGenerated}"/>

configuration.xml

Table configuration for add to configuration.xml node <configuration>:

<tables>
    <table id="${widgetID}" name="${widgetID}_table">
        <columnText id="${widgetID}" name="${widgetID}_column" />
    </table>
    <table id="${widgetIdDependent}" name="${widgetIdDependent}_table">
        <columnText id="${widgetIdDependent}" name="${widgetIdDependent}_column" />
        <columnPointer id="${widgetIdDependent}_${widgetID}" name="${widgetIdDependent}_${widgetID}_column" required="true"> <table>${widgetID}</table> <column>${widgetID}</column></columnPointer>
    </table>
</tables>

data for data.xml

  • ${numberIncrement} - Starts from 1. Take biggest row id and increment by 1.
  • ${dropdownItemsListRows} - based on user entered data into "dropdown items", repeat for each user entered item:
<row id="${widgetID}${numberIncrement}">
    <column id="${widgetID}">
        <value>${dropdownListItem}</value>
    </column>			
</row>
  • ${dropdownItemsListRowsDependent} - based on user entered data into "dropdown items", repeat for each user entered item:
<row id="${numberIncrement}">
    <column id="${widgetIdDependent}">
        <value>${dropdownListItem}</value>
    </column>	
    <column id="${widgetIdDependent}_{widgetID}">
        <ref id="${widgetID}${numberIncrement}"/>
    </column>			
</row>
  • ${dropdownListItem} must comply with RULES

Data configuration for add to data.xml node tables:

<tables>
	<table id="${widgetID}">
		${dropdownItemsListRows}
	</table>
        <table id="${widgetIdDependent}">
		${dropdownItemsListRowsDependent}
	</table>
</tables>