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

Load record column value

Widget is used to load value from record in database and set it into a widget.
Widget is hidden.

Widget id, ${gbamID}:

actionLoadRecordColumnValue

Back to GBAM widgets table

Datatypes

Value is stored into compatible widget depending on source of data. Widgets which are not of same datatype should not be shown in the list of targets available to store the information.
If data comes from column which is text datatype then it should only be possible to store to widget which saves it's data as text datatype.

Predefined user data

PreLoaded

Properties panel

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

GENERAL
VALIDATIONS
  • -
internal validators
  • -
ACTION
  • "choose query type", ${queryType} based on query type different queries will be activated. current query types:
  • query single result singleResult
  • query sorted result sortedResult
  • "value to load", ${widgetValueToLoadColumnId} widget on screen which value should be loaded
  • "key", ${queryKey} which can be @variable/by default selection selects first widget on screen which has selected "is part of database" to true, the android:id. User can change it to any widget which have checkbox "is part of database" set to true. Value is then copied from widget ${keyWidgetId} to it's variable ${queryKey}. In case that widget is a "variable" then value is copied from variable i.e. Ginstr username
  • "save result to", widget into which result is stored ${targetWidget}, which is formed ${widgetID} widget id's. All widgets that are on screen which have checkbox "is part of database", user can change selection. It's a dropdown.
  • "sort key", visible only if query sorted result is selected ${sortByWidgetId} by default selection selects first widget on screen which has selected "is part of database" to true, the android:id. User can change it to any widget which have checkbox "is part of database" set to true.
  • "clean widgets on no result", cleans widgets that receive result if nothing is returned ${cleanWidgetsOnNoResult}, only if checkbox selected. By default is selected
  • "on event" triggers the action in common widget code at specific event. Events are are listed in a dropdown can be:
  • screen load widget code is added into root node of the screen in attribute gn:act_beforeLoad as:
gn:act_beforeLoad="[gn:act_trigger]|[@+id/idOfCurrentWidget,gn:act_set]"
gn:act_set="Common widget code"
[gn:act_trigger]|[@+id/idOfCurrentWidget,gn:act_set]
as attribute to Button save widget:
gn:act_set="Common widget code"
needs to be added to widget Button save at:
Two options when to execute:
[gn:act_trigger]|[@+id/idOfCurrentWidget,gn:act_set]
as attribute to Button clean widgets widget:
gn:act_set="Common widget code"
Two options when to execute:
Two options when to execute:
[gn:act_trigger]|[@+id/idOfCurrentWidget,gn:act_set]
as attribute to Button query widget:
gn:act_set="Common widget code"
ACTION MESSAGES
DATABASE
  • -

Code snippets

GBAM Code Variables

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

  • ${widgetID}, {variableId} is generated based on the ${widgetID}
  • ${tableName}
  • "target widget", ${targetWidget}, formed as ${widgetID} widget id's. All widgets on screen which have checkbox "is part of database", user can change selection.
  • ${queryType} = singleResult
[gn:act_rawQueryToWidgets]|[${tableName},${widgetID}${tableName};${widgetValueToLoadColumnId};@variable/${resultVariable};@variable/${queryKey}]


${querySuccess}=

[gn:act_getVariableToWidget]|[@variable/${resultVariable},@+id/${targetWidget}]


in queries.xml, ${queriesXml}=

    <query
        id="${widgetID}${tableName}" 
        columns="${widgetValueToLoadColumnId}"
        keys="${keyDbColumn}"/>
  • ${queryType} = sortedResult
[gn:act_rawQueryToWidgets]|[${tableName},${widgetID}${tableName},,,sortreversetop;${widgetValueToLoadColumnId};@variable/${resultVariable};@variable/${queryKey},@variable/${sortByWidgetId}]


${querySuccess}=

[gn:act_getVariableToWidget]|[@variable/${resultVariable},@+id/${targetWidget}]


in queries.xml, ${queriesXml}=

    <query
        id="${widgetID}${tableName}" 
        columns="${widgetValueToLoadColumnId}"
        keys="${keyDbColumn},${sortDbColumn}"/>
  • ${cleanWidgetsOnNoResult} following code for clean is added if checkbox is selected:
    [gn:act_resetVariables]|[@variable/${resultVariable}],
    [gn:act_cleanWidgets]|[@+id/${targetWidget}]
  • ${keyDbColumn} - column name of widget which links to @variable/${queryKey} which used as key
  • ${resultVariable}, value is stored into variable after query before setting it to widget ${targetWidget}

Common widget code

screen.xml
    [gn:act_if]|[[gn:act_hasTableRights]|[${tableName}!=R]--
          [gn:act_toast]|[@string/${$noReadRightsToast}];
    	  [gn:act_break]|[]],
    [gn:act_setVariable]|[@variable/${queryKey},${keyWidgetId}],
    [gn:act_if]|[${queryType}--
		${querySuccess}
	::
                ${cleanWidgetsOnNoResult}]

queries.xml

Add to queries.xml : ${queriesXml}