(→Filtering) |
|||
Line 96: | Line 96: | ||
==Filtering== | ==Filtering== | ||
− | Once data is loaded from the database it can be filtered by a filter mechanism. You can also filter the data loaded into the <code>[[GnListView]]</code> by using the following filter types: | + | : Once data is loaded from the database it can be filtered by a filter mechanism. You can also filter the data loaded into the <code>[[GnListView]]</code> by using the following filter types: |
− | *<code>VALUE</code> | + | * <code>VALUE</code> |
− | *<code>WIDGET</code> | + | * <code>WIDGET</code> |
− | *<code>KEYWORD</code> | + | * <code>KEYWORD</code> |
− | Filters can also be chained by chain words: | + | : Filters can also be chained by chain words: |
− | *<code>AND</code> | + | * <code>AND</code> |
− | *<code>OR</code> | + | * <code>OR</code> |
− | If the filters are chained then each of filter statements must be true in order to show some record that is in <code>[[GnListView]]</code> data. | + | : If the filters are chained then each of filter statements must be true in order to show some record that is in <code>[[GnListView]]</code> data. |
− | :i.e.<code>[@+id/widgetOne]|[=]|[columnOne],[AND]|[#today]|[=]|[timestamp],[AND]|[dog]|[=]|[columnAnimalType]</code> | + | : i.e.<code>[@+id/widgetOne]|[=]|[columnOne],[AND]|[#today]|[=]|[timestamp],[AND]|[dog]|[=]|[columnAnimalType]</code> |
− | The upper statement filters the <code>[[GnListView]]</code> in the following way: | + | : The upper statement filters the <code>[[GnListView]]</code> in the following way: |
− | :'''IF''' the widget that has id “<code>@+id/widgetOne</code>” has a value equal to the value in <code>columnOne</code> in listview rows '''AND''' if <code>timestamp</code> value in listview rows is within today '''AND''' if <code>columnAnimalType</code> value in listview rows is equal to “<code>dog</code>”, then the row from listview rows will be displayed in <code>[[GnListView]]</code>. | + | : '''IF''' the widget that has id “<code>@+id/widgetOne</code>” has a value equal to the value in <code>columnOne</code> in listview rows '''AND''' if <code>timestamp</code> value in listview rows is within today '''AND''' if <code>columnAnimalType</code> value in listview rows is equal to “<code>dog</code>”, then the row from listview rows will be displayed in <code>[[GnListView]]</code>. |
− | Based the example above, the filter chaining definition is: | + | : Based the example above, the filter chaining definition is: |
− | :<code>[CHAIN WORD]|[FILTER],[CHAIN WORD]|[FILTER1]…</code> | + | : <code>[CHAIN WORD]|[FILTER],[CHAIN WORD]|[FILTER1]…</code> |
− | General filter <code>[FILTER]</code> definition is: | + | : General filter <code>[FILTER]</code> definition is: |
− | :<code>[VALUE]|[COMPARATOR]|[COLUMNID]</code> | + | : <code>[VALUE]|[COMPARATOR]|[COLUMNID]</code> |
− | Filters behave differently depending on the content of the <code>[VALUE]</code> field. | + | : Filters behave differently depending on the content of the <code>[VALUE]</code> field. |
===<code>[VALUE]</code> field special characters=== | ===<code>[VALUE]</code> field special characters=== | ||
Line 141: | Line 141: | ||
|} | |} | ||
− | In order to use '''special characters''' as standard text you need to escape them as follows: <code>\::</code>, <code>\*</code>, <code>\#</code>, <code>\@+id/</code> or <code>\\</code> | + | : In order to use '''special characters''' as standard text you need to escape them as follows: <code>\::</code>, <code>\*</code>, <code>\#</code>, <code>\@+id/</code> or <code>\\</code> |
===Comparators=== | ===Comparators=== | ||
− | Comparators define the relation between the two values that are being compared. | + | : Comparators define the relation between the two values that are being compared. |
− | + | : The following comparators can be used to compare: | |
− | The following comparators can be used to compare: | ||
− | |||
{| class="wikitable sortable" style="font-size: 85%; text-align: left;" | {| class="wikitable sortable" style="font-size: 85%; text-align: left;" | ||
|- | |- | ||
Line 168: | Line 166: | ||
====<code>[VALUE]</code> filter==== | ====<code>[VALUE]</code> filter==== | ||
− | :Compares a value against value loaded into <code>[[GnListView]]</code> data rows. | + | : Compares a value against value loaded into <code>[[GnListView]]</code> data rows. |
− | + | : The definition of value filter is as follows: | |
− | :The definition of value filter is as follows : | + | : <code>[VALUE]|[COMPARATOR]|[COLUMNID]</code>:i.e. <code>[two]|[=]|[columnOne]</code> |
− | : | + | : The following filter will compare data row value if is equal to <code>two</code>, filter will return <code>true</code> and data row loaded into <code>[[GnListView]]</code>. |
− | |||
− | :The following filter will compare data row value if is equal to <code>two</code>, filter will return <code>true</code> and data row loaded into <code>[[GnListView]]</code>. | ||
====<code>[WIDGET]</code> filter==== | ====<code>[WIDGET]</code> filter==== | ||
− | :If <code>[VALUE]</code> field contains special character <code>@+id/</code> filter will behave as '''Widget filter'''. | + | : If <code>[VALUE]</code> field contains special character <code>@+id/</code> filter will behave as '''Widget filter'''. |
− | + | : <code>[WIDGET]</code> filter compares listview datarow value with value of a certain widget. | |
− | : | + | : <code>[@+id/WIDGET_ID]|[COMPARATOR]|[COLUMNID]</code>:i.e. <code>[@+id/widgetOne]|[=]|[columnA]</code> |
− | + | : This filter checks if a widget with id <code>@+id/widgetOne</code> has value equal to <code>columnA</code> of listview datarow. If <code>true</code> row will be shown. | |
− | : | ||
− | |||
− | :This filter checks if a widget with id <code>@+id/widgetOne</code> has value equal to <code>columnA</code> of listview datarow. If <code>true</code> row will be shown. | ||
====<code>[KEYWORD]</code> filter==== | ====<code>[KEYWORD]</code> filter==== | ||
− | : | + | : <code>[KEYWORD]</code> filter compares values from list with special values that cannot be obtained by other means. |
− | : | + | : <code>[#KEYWORD]|[COMPARATOR]|[COLUMNID]</code> |
=====<code>#today</code>===== | =====<code>#today</code>===== | ||
− | :Keyword <code>#today</code> checks if value from listview is within today's date. If it is then it returns <code>true</code> and row is displayed. | + | : Keyword <code>#today</code> checks if value from listview is within today's date. If it is then it returns <code>true</code> and row is displayed. |
− | + | : i.e. <code>[#today]|[=]|[timestamp]</code> is timestamp field within today's date | |
− | + | : When using the timestamp the <code>[[Datatypes#dateTime|dateTime]]</code> [[Datatypes|datatype]] must be used. | |
− | :When using the timestamp the <code>[[Datatypes#dateTime|dateTime]]</code> [[Datatypes|datatype]] must be used. | ||
==pointer additional widget attributes== | ==pointer additional widget attributes== |
Revision as of 09:23, 22 March 2017
GnListView
- Widget XML tag
<com.ginstr.widgets.GnListView>
- Description
GnListView
is used to show data in a table appearance, with header on the top and data in rows with cells below.
XML Attributes Description
Attribute | Description |
---|---|
gn:data_columns_width{n} | Defines the width of each column from left to right that appears in listview
|
gn:data_columns_name{n} | Defines the names from left to right that will appear in header columns
|
gn:data_columns_settings{n} | Defines the settings for each column from left to right that is displayed in listview.
|
gn:data_columns_id{n} | Defines column identifiers
|
gn:data_columns_type | Defines cell type for each row which will display data
|
gn:data_filters{n} | Defines filter parameter to sort data
|
gn:data_columns_sort{n} | Defines column by which data will be sorted
|
gn:lstRefreshNoFilter | Defines that on refresh data will not be filtered (used only in special cases when business logic implementation is used)
|
gn:lstExpandToFitChildren | Stretches GnListView to load all children without scroll
|
Example
<com.ginstr.widgets.GnListView android:id="@+id/lstResidents" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_gravity="center_horizontal" android:background="#e1e1e1" gn:data_columns_name="resident_nfcTagUid,resident_firstName,resident_lastName,resident_roomNo,resident_buildingCode" gn:data_columns_id="resident_nfcTagUid,resident_firstName,resident_lastName,resident_roomNo,resident_buildingCode" gn:data_columns_type="text,text,text,text,text" gn:serverTableGenerator="ignore" gn:lstRefreshNoFilter="true" gn:s_listSelector="#00000000" gn:custom_xml="customList_listview.xml" gn:custom_header_xml="residentsList_header.xml" gn:custom_row_xml="residentsList_row.xml" gn:complex_cell_layout="true" />
Filtering
- Once data is loaded from the database it can be filtered by a filter mechanism. You can also filter the data loaded into the
GnListView
by using the following filter types:
VALUE
WIDGET
KEYWORD
- Filters can also be chained by chain words:
AND
OR
- If the filters are chained then each of filter statements must be true in order to show some record that is in
GnListView
data. - i.e.
[@+id/widgetOne]|[=]|[columnOne],[AND]|[#today]|[=]|[timestamp],[AND]|[dog]|[=]|[columnAnimalType]
- The upper statement filters the
GnListView
in the following way: - IF the widget that has id “
@+id/widgetOne
” has a value equal to the value incolumnOne
in listview rows AND iftimestamp
value in listview rows is within today AND ifcolumnAnimalType
value in listview rows is equal to “dog
”, then the row from listview rows will be displayed inGnListView
.
- Based the example above, the filter chaining definition is:
[CHAIN WORD]|[FILTER],[CHAIN WORD]|[FILTER1]…
- General filter
[FILTER]
definition is: [VALUE]|[COMPARATOR]|[COLUMNID]
- Filters behave differently depending on the content of the
[VALUE]
field.
[VALUE]
field special characters
Special Character | Description |
---|---|
::
|
Defines range in VALUE (turns filter into RANGE filter) (not yet implemented) |
*
|
Equivalent to like |
#
|
Keyword identifier (turns filter into KEYWORD filter) |
@+id/
|
Widget id |
\
|
Escape character |
- In order to use special characters as standard text you need to escape them as follows:
\::
,\*
,\#
,\@+id/
or\\
Comparators
- Comparators define the relation between the two values that are being compared.
- The following comparators can be used to compare:
Comparator Symbol | Description | Value Types Allowed |
---|---|---|
=
|
Equals to values | STRING , NUMBER
|
c=
|
Case sensitive equals to values | STRING , NUMBER
|
>
|
Greater than value | NUMBER
|
[VALUE]
filter
- Compares a value against value loaded into
GnListView
data rows. - The definition of value filter is as follows:
[VALUE]|[COMPARATOR]|[COLUMNID]
:i.e.[two]|[=]|[columnOne]
- The following filter will compare data row value if is equal to
two
, filter will returntrue
and data row loaded intoGnListView
.
[WIDGET]
filter
- If
[VALUE]
field contains special character@+id/
filter will behave as Widget filter. [WIDGET]
filter compares listview datarow value with value of a certain widget.[@+id/WIDGET_ID]|[COMPARATOR]|[COLUMNID]
:i.e.[@+id/widgetOne]|[=]|[columnA]
- This filter checks if a widget with id
@+id/widgetOne
has value equal tocolumnA
of listview datarow. Iftrue
row will be shown.
[KEYWORD]
filter
[KEYWORD]
filter compares values from list with special values that cannot be obtained by other means.[#KEYWORD]|[COMPARATOR]|[COLUMNID]
#today
- Keyword
#today
checks if value from listview is within today's date. If it is then it returnstrue
and row is displayed. - i.e.
[#today]|[=]|[timestamp]
is timestamp field within today's date - When using the timestamp the
dateTime
datatype must be used.
pointer additional widget attributes
Attribute | Description |
---|---|
gn:data_source_request | id of query which will be used to get pointed value
|
gn:data_source_table | name of table which will get queried
|
gn:data_source_field | column of referenced table which we would like to display supported referencing columns of data type text
|
gn:data_source_keys | optional
query keys in case referenced table values need to be reduced. This optimises memory on large table loads.
|