DynamicTableView

Static Public Attributes

The DynamicTableView class has the following static public attributes:

const string ROW_ID_KEY = "_rowID" Key that will be used for the row ID in the update callback.
const string COLUMN_CONFIG_KEY = "_config" Key that must be used in column definitions to specify the mandatory config that will be shown in the column.
const string COLUMN_ID_KEY = "_colID" Key that must be used in column definitions to specify the optional ID of the column.
const string COLUMN_CONVERT_KEY = "_convert" Key that must be used in column definitions to specify the optional value conversion method.
const string COLUMN_HIDDEN_KEY = "_hidden" Key that must be used in column definitions to specify that the column is hidden (only used for sorting and filtering), but its values will not be transmitted to the receiver.
const string COLUMN_FAST_UPDATE_KEY = "_fastUpdate" Key that identifies columns that should be optimized for frequent value updates. These columns cannot be used for sorting and filtering, but are therefore handled more efficiently when being updated.
const int MAX_VIEW_ROW_COUNT = 200; Maximum number of rows that can be displayed.

DynamicTableView Class - Constructor

DynamicTableView(shared_ptr<void> receiver,
                 function_ptr updateCB = nullptr,
                 mixed userData = 0, // needs to be mixed because of default value
                 int blockingTime = -1,
                 function_ptr staticDataMapCB = nullptr,
                 function_ptr addDataMapCB = nullptr,
                 bool completeUpdates = false)

Parameters

Parameter Description
receiver Object instance that will receive all callbacks.
updateCB

Pointer to a method on "receiver" that will be called whenever the viewed part of the table changes.

The function must have the following signature:
void name(const anytype &userData, const mapping &updates)
name
Name of the function.
userData
User data that has been passed with this constructor.
updates
Mapping describing the updates to the viewed part of the table.
It always contains the key "updateType" that describes the changes that happened. It can have three values:
"data"
Only the data in one or more visible cells has changed.
In this case, a second key "changedRows" is present, which contains the rows and their cell values which have changed.
"complete"
Complete ordered list of visible rows with all data.
Under the key "rows", the list of new data rows is included in the callback data. Each row always contains a "_rowID" and data for all the columns that have been specified.
"reorder"
The paramter is the same as "complete", but each row contains only a "_rowID" and change cell values. All other values for the row are unchanged and have to be reused, as they have been included in earlier updates.
In the simplest case, when only existing rows are reordered, each row only contains a "_rowID", and all data has already been included in earlier updates.
Note: The number of rows included is always the number of rows that should be visible. Whenever a row is not included in this list, its data can be removed, because the complete row data will be included in an update when that row becomes visible again.
userData Data that will be included in each call from this instance to a callback.
blockingTime Time range in msec where the call of the callback function is blocked by open queries.
staticDataMapCB

(optional) Pointer to a method on "receiver" that will be called before static data for a row ID is loaded.

This method can add static data (keyed by column IDs) to the mapping passed as first parameter, and all static data added this way is used without calling the column's _convert method. The function must have the following signature:
void methodName(mapping &values, const anytype &userData, const string &rowId)
values
Mapping where static values can be added.
userData
User data that has been passed with this constructor.
rowId
ID of the row for which static data is requested.
addDataMapCB

(optional) Pointer to a method on "receiver" that will be called before data for a row ID is sent to updateCB.

This method can add data to the mapping passed as first parameter, and all data added this way is used without any further processing, keys for these values must be different from column IDs used by this DynamicTableView. In contrast to "staticDataMapCB" this is only called for rows that are actually sent to "updateCB", not for all rows in the table. However, data is not cached, but "addDataMapCB" will be called every time before "updateCB" is called. The function must have the following signature:
void methodName(mapping &values, const anytype &userData, const string &rowId)
values
Mapping where values can be added.
userData
User data that has been passed with this constructor.
completeUpdates (optional) If "true", every call to "updateCB" will be a complete update, containing all visible rows and not only changes to the last call. The default value is "false".

This is an example using a receiver class called "Receiver":

class Receiver
{
// the update callback just shows the list of received changes
  public updateCB(const anytype &userData, const mapping &changes)
  {
    DebugTN(changes);
  }

// callback for static data: just invents some data on the fly
  public string staticData(const anytype &userData, const string &rowID, const string &colID)
  {
    return strtoupper(rowID + "/" + colID);
  }

// a simple value converter that converts to ulong
  public ulong toUlong(const anytype &userData, const string &rowID, const string &colID, const anytype &value)
  {
    return (ulong)value;
  }
};

main()
{
  shared_ptr<Receiver> rcv = new Receiver();
  DynamicTableView view = DynamicTableView(rcv, Receiver::updateCB);
                
  // now use view.setDpeNames() or view.setQuery() to connect to data.
}