setQuery
Defines columns and a query to define the table to view. Either this or setDpeNames needs to be called in order to initialize this instance.
Synopsis
bool setQuery(const dyn_mapping &columnDefs,
const string &queryFromWhere,
function_ptr rowIdCB = nullptr)
Parameters
Parameter | Description |
---|---|
columnDefs |
Definition of the table's columns. For each column, this parameter contains a mapping with the following keys. (For
each key, a constant is defined as well, see code example
below.):
|
queryFromWhere | Contains the rest of the SQL statement that defines the data of this table. Since the SELECT clause is generated from "columnDefs", this always starts with the "FROM" clause, followed possibly by a where clause. |
rowIdCB |
(optional) Pointer to a method on "receiver" that will be called whenever a row ID is to be created for a
datapoint(element) name. If not given, the datapoint(element) name will be used as the row ID. The function must
have the following signature:
|
Return value
Returns "true" when the query could be generated and started successfully.
dyn_mapping columns =
makeDynMapping(
// simple column containing the online value
makeMapping(DynamicTableView::COLUMN_CONFIG_KEY, ":_online.._value",
DynamicTableView::COLUMN_ID_KEY, "value",
DynamicTableView::COLUMN_FAST_UPDATE_KEY, true ),
// column containing the status, converted to unsigned long by Receiver::toUlong()
makeMapping(DynamicTableView::COLUMN_CONFIG_KEY, ":_online.._status",
DynamicTableView::COLUMN_ID_KEY, "status",
DynamicTableView::COLUMN_CONVERT_KEY, Receiver::toUlong),
// column containing static data that is generated by Receiver::staticData()
// and hidden (only used e. g. for sorting, but never displayed to the user)
makeMapping(DynamicTableView::COLUMN_ID_KEY, "sortVal",
DynamicTableView::COLUMN_HIDDEN_KEY, true,
DynamicTableView::COLUMN_CONVERT_KEY, Receiver::staticData));
string queryPart = "FROM '*' WHERE _DPT=\"ExampleDP_Float\"";
view.setQuery(columns, queryPart);
Assignment
Availability
CTRL