(→[VALUE] field special characters) |
m (formatting) |
||
Line 1: | Line 1: | ||
<div style="float:right; clear:both; margin-left:0.5em;">__TOC__</div> | <div style="float:right; clear:both; margin-left:0.5em;">__TOC__</div> | ||
<span STYLE="font-size: xx-large"><code>GnListView</code></span> | <span STYLE="font-size: xx-large"><code>GnListView</code></span> | ||
− | [[Category:Widget_Library]] | + | [[Category:Widget_Library]][[Category:Controls]] |
;Widget XML tag | ;Widget XML tag | ||
Line 7: | Line 7: | ||
;Description | ;Description | ||
− | : <code>GnListView</code> is used to show data in a table appearance, with header on the top and data in rows with cells below. | + | : <code>'''GnListView'''</code> is used to show data in a table appearance, with header on the top and data in rows with cells below. |
==XML Attributes Description== | ==XML Attributes Description== | ||
Line 15: | Line 15: | ||
! scope="col" | Description | ! scope="col" | Description | ||
|- | |- | ||
− | | title="Attribute" | gn:data_columns_width{n} | + | | title="Attribute" | <code>gn:data_columns_width{n}</code> |
| title="Description" | Defines the width of each column from left to right that appears in listview | | title="Description" | Defines the width of each column from left to right that appears in listview | ||
Can be | Can be | ||
− | * hardcoded, i.e. 50,50,50 | + | * hardcoded, i.e. <code>50,50,50</code> |
|- | |- | ||
− | | title="Attribute" | gn:data_columns_name{n} | + | | title="Attribute" | <code>gn:data_columns_name{n}</code> |
| title="Description" | Defines the names from left to right that will appear in header columns | | title="Description" | Defines the names from left to right that will appear in header columns | ||
Can be | Can be | ||
− | * hardcoded, i.e. resident_nfcTagUid,resident_firstName | + | * hardcoded, i.e. <code>resident_nfcTagUid,resident_firstName</code> |
* <code>@string</code> | * <code>@string</code> | ||
|- | |- | ||
− | | title="Attribute" | gn:data_columns_settings{n} | + | | title="Attribute" | <code>gn:data_columns_settings{n}</code> |
| title="Description" | Defines the settings for each column from left to right that is displayed in listview. | | title="Description" | Defines the settings for each column from left to right that is displayed in listview. | ||
If there is a single column to be shown in listview there is no separator between settings for columns. | If there is a single column to be shown in listview there is no separator between settings for columns. | ||
− | If there are 2 or more columns whose settings should be configured “pipe” (<code>|</code>) is used to separate them i.e. “<code>settingsColumn1|settingsColumn2|…</code>”. | + | If there are 2 or more columns whose settings should be configured, a “pipe” character (<code>|</code>) is used to separate them i.e. “<code>settingsColumn1|settingsColumn2|…</code>”. |
Can be | Can be | ||
* <code>format</code> – converting long to human readable date and time, correct formats [http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html here] | * <code>format</code> – converting long to human readable date and time, correct formats [http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html here] | ||
|- | |- | ||
− | | title="Attribute" | gn:data_columns_id{n} | + | | title="Attribute" | <code>gn:data_columns_id{n}</code> |
| title="Description" | Defines column identifiers | | title="Description" | Defines column identifiers | ||
Line 41: | Line 41: | ||
Can be | Can be | ||
− | * hardcoded, i.e. resident_nfcTagUid,resident_firstName | + | * hardcoded, i.e. <code>resident_nfcTagUid,resident_firstName</code> |
* <code>@string</code> | * <code>@string</code> | ||
|- | |- | ||
− | | title="Attribute" | gn:data_columns_type | + | | title="Attribute" | <code>gn:data_columns_type</code> |
| title="Description" | Defines cell type for each row which will display data | | title="Description" | Defines cell type for each row which will display data | ||
Can be | Can be | ||
Line 53: | Line 53: | ||
* <code>phoneNumber</code> | * <code>phoneNumber</code> | ||
|- | |- | ||
− | | title="Attribute" | gn:data_filters{n} | + | | title="Attribute" | <code>gn:data_filters{n}</code> |
| title="Description" | Defines filter parameter to sort data | | title="Description" | Defines filter parameter to sort data | ||
− | Once data is loaded into <code>GnListView</code>, it can be filtered by defining filter parameter. | + | Once data is loaded into <code>[[GnListView]]</code>, it can be filtered by defining filter parameter. |
Filters are separated by <code>,</code> (comma symbol) and they have special syntax. More about filters [[#Filtering|here]]. | Filters are separated by <code>,</code> (comma symbol) and they have special syntax. More about filters [[#Filtering|here]]. | ||
|- | |- | ||
− | | title="Attribute" | gn:data_columns_sort{n} | + | | title="Attribute" | <code>gn:data_columns_sort{n}</code> |
| title="Description" | Defines column by which data will be sorted | | title="Description" | Defines column by which data will be sorted | ||
Line 67: | Line 67: | ||
For example if dbRequest has columns: name,surname,timestamp, and name is set as a value for this attribute then all rows will be sorted ascending by name. | For example if dbRequest has columns: name,surname,timestamp, and name is set as a value for this attribute then all rows will be sorted ascending by name. | ||
|- | |- | ||
− | | title="Attribute" | gn:lstRefreshNoFilter | + | | title="Attribute" | <code>gn:lstRefreshNoFilter</code> |
| title="Description" | Defines that on refresh data will not be filtered (used only in special cases when business logic implementation is used) | | title="Description" | Defines that on refresh data will not be filtered (used only in special cases when business logic implementation is used) | ||
Line 76: | Line 76: | ||
* <code>false</code> | * <code>false</code> | ||
|- | |- | ||
− | | title="Attribute" | gn:lstExpandToFitChildren | + | | title="Attribute" | <code>gn:lstExpandToFitChildren</code> |
| title="Description" | Stretches <code>[[GnListView]]</code> to load all children without scroll | | title="Description" | Stretches <code>[[GnListView]]</code> to load all children without scroll | ||
Used only if listView is <code>com.ginstr.widgets.internal.ExpandableHeightListView</code> in <code>control/widget_en_listview.xml</code>. | Used only if listView is <code>com.ginstr.widgets.internal.ExpandableHeightListView</code> in <code>control/widget_en_listview.xml</code>. | ||
− | If set to <code>true</code>, GnListView will stretch to load all children without scroll. | + | If set to <code>true</code>, <code>[[GnListView]]</code> will stretch to load all children without scroll. |
Can be | Can be | ||
Line 86: | Line 86: | ||
* <code>false</code> | * <code>false</code> | ||
|- | |- | ||
− | | title="Attribute" | gn:complex_cell_layout | + | | title="Attribute" | <code>gn:complex_cell_layout</code> |
| title="Description" | to create complex list layouts based on one cell in row | | title="Description" | to create complex list layouts based on one cell in row | ||
Line 93: | Line 93: | ||
* <code>false</code> | * <code>false</code> | ||
|- | |- | ||
− | | title="Attribute" | gn:custom_xml | + | | title="Attribute" | <code>gn:custom_xml</code> |
| title="Description" | customised XML listview layout | | title="Description" | customised XML listview layout | ||
Line 99: | Line 99: | ||
* hardcoded - the name of xml file | * hardcoded - the name of xml file | ||
|- | |- | ||
− | | title="Attribute" | gn:custom_header_xml | + | | title="Attribute" | <code>gn:custom_header_xml</code> |
| title="Description" | customised XML listview header layout | | title="Description" | customised XML listview header layout | ||
Line 105: | Line 105: | ||
* hardcoded - the name of xml file | * hardcoded - the name of xml file | ||
|- | |- | ||
− | | title="Attribute" | gn:custom_row_xml | + | | title="Attribute" | <code>gn:custom_row_xml</code> |
| title="Description" | customised XML row layout | | title="Description" | customised XML row layout | ||
Line 201: | Line 201: | ||
| title="Value Types Allowed" | <code>NUMBER</code> | | title="Value Types Allowed" | <code>NUMBER</code> | ||
|} | |} | ||
+ | |||
===Filters=== | ===Filters=== | ||
{| class="wikitable sortable" style="font-size: 85%; text-align: left;" | {| class="wikitable sortable" style="font-size: 85%; text-align: left;" | ||
Line 207: | Line 208: | ||
! scope="col" | Description | ! scope="col" | Description | ||
|- | |- | ||
− | | title="Filter" | [VALUE] | + | | title="Filter" | <code>[VALUE]</code> |
| title="Description" | | | title="Description" | | ||
: Compares a value against value loaded into <code>[[GnListView]]</code> data rows. | : Compares a value against value loaded into <code>[[GnListView]]</code> data rows. | ||
Line 214: | Line 215: | ||
: 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>. | ||
|- | |- | ||
− | | title="Filter" | [WIDGET] | + | | title="Filter" | <code>[WIDGET]</code> |
| title="Description" | | | title="Description" | | ||
: 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'''. | ||
Line 221: | Line 222: | ||
: 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. | ||
|- | |- | ||
− | | title="Filter" | [KEYWORD] | + | | title="Filter" | <code>[KEYWORD]</code> |
| title="Description" | | | title="Description" | | ||
: <code>[KEYWORD]</code> filter compares values from list with special values that cannot be obtained by other means. | : <code>[KEYWORD]</code> filter compares values from list with special values that cannot be obtained by other means. | ||
Line 236: | Line 237: | ||
! scope="col" | Description | ! scope="col" | Description | ||
|- | |- | ||
− | | title="Attribute" | gn:data_source_request | + | | title="Attribute" | <code>gn:data_source_request</code> |
| title="Description" | id of query which will be used to get pointed value | | title="Description" | id of query which will be used to get pointed value | ||
: Can be | : Can be | ||
* hardcoded | * hardcoded | ||
|- | |- | ||
− | | title="Attribute" | gn:data_source_table | + | | title="Attribute" | <code>gn:data_source_table</code> |
| title="Description" | name of table which will get queried | | title="Description" | name of table which will get queried | ||
: Can be | : Can be | ||
* hardcoded | * hardcoded | ||
|- | |- | ||
− | | title="Attribute" | gn:data_source_field | + | | title="Attribute" | <code>gn:data_source_field</code> |
| title="Description" | column of referenced table which we would like to display supported referencing columns of data type <code>[[Datatypes#text|text]]</code> | | title="Description" | column of referenced table which we would like to display supported referencing columns of data type <code>[[Datatypes#text|text]]</code> | ||
: Can be | : Can be | ||
* hardcoded | * hardcoded | ||
|- | |- | ||
− | | title="Attribute" | gn:data_source_keys | + | | title="Attribute" | <code>gn:data_source_keys</code> |
| title="Description" | <div style="text-align: right;">'''optional'''</div> | | title="Description" | <div style="text-align: right;">'''optional'''</div> | ||
query keys in case referenced table values need to be reduced. This optimises memory on large table loads. | query keys in case referenced table values need to be reduced. This optimises memory on large table loads. | ||
Line 263: | Line 264: | ||
Special widget which has multiple XML files defining multiple parts of this composite widget: | Special widget which has multiple XML files defining multiple parts of this composite widget: | ||
===widget_en_listview_row_container.xml=== | ===widget_en_listview_row_container.xml=== | ||
− | : defines how listview container appearance will look | + | : defines how listview container appearance will look |
===widget_en_listview_header_container.xml=== | ===widget_en_listview_header_container.xml=== | ||
− | : defines how header container appearance will look | + | : defines how header container appearance will look |
===widget_en_listview_column_string.xml=== | ===widget_en_listview_column_string.xml=== | ||
− | : defines how column cell of type string will look | + | : defines how column cell of type string will look |
:{| class="wikitable sortable" style="font-size: 85%; text-align: left;" | :{| class="wikitable sortable" style="font-size: 85%; text-align: left;" | ||
|- | |- | ||
Line 280: | Line 281: | ||
===widget_en_listview_column_pointer.xml=== | ===widget_en_listview_column_pointer.xml=== | ||
− | : defines how column cell of type pointer will look | + | : defines how column cell of type pointer will look |
:{| class="wikitable sortable" style="font-size: 85%; text-align: left;" | :{| class="wikitable sortable" style="font-size: 85%; text-align: left;" | ||
|- | |- |
Revision as of 10:19, 12 July 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
Can be
|
gn:data_columns_name{n}
|
Defines the names from left to right that will appear in header columns
Can be
|
gn:data_columns_settings{n}
|
Defines the settings for each column from left to right that is displayed in listview.
If there is a single column to be shown in listview there is no separator between settings for columns. If there are 2 or more columns whose settings should be configured, a “pipe” character ( Can be
|
gn:data_columns_id{n}
|
Defines column identifiers
If the data is loading from database that has columns i.e. Can be
|
gn:data_columns_type
|
Defines cell type for each row which will display data
Can be
|
gn:data_filters{n}
|
Defines filter parameter to sort data
Once data is loaded into Filters are separated by |
gn:data_columns_sort{n}
|
Defines column by which data will be sorted
Currently, sorting only accepts ascending sort by columnID defined by value of this attribute. For example if dbRequest has columns: name,surname,timestamp, and name is set as a value for this attribute then all rows will be sorted ascending by name. |
gn:lstRefreshNoFilter
|
Defines that on refresh data will not be filtered (used only in special cases when business logic implementation is used)
This attribute is not relevant to designer and if developing a standard ginstr app then it can be omitted. Can be
|
gn:lstExpandToFitChildren
|
Stretches GnListView to load all children without scroll
Used only if listView is If set to Can be
|
gn:complex_cell_layout
|
to create complex list layouts based on one cell in row
Can be
|
gn:custom_xml
|
customised XML listview layout
Can be
|
gn:custom_header_xml
|
customised XML listview header layout
Can be
|
gn:custom_row_xml
|
customised XML row layout
Can be
|
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
|
Filters
Filter | Description |
---|---|
[VALUE]
|
|
[WIDGET]
|
|
[KEYWORD]
|
|
pointer additional XML 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.
|
Alternative layout
Alternative layout can be set into control folder.
Special widget which has multiple XML files defining multiple parts of this composite widget:
widget_en_listview_row_container.xml
- defines how listview container appearance will look
widget_en_listview_header_container.xml
- defines how header container appearance will look
widget_en_listview_column_string.xml
- defines how column cell of type string will look
id Type @+id/tvDisplayView
TextView
widget_en_listview_column_pointer.xml
- defines how column cell of type pointer will look
id Type @+id/tvDisplayView
TextView
widget_en_listview.xml
- defines the appearance of the listview container
id Type @+id/lstHeader
FrameLayout
@+id/lstListView
ListView