A resource that serializes data from a data model. More...
#include <Wt/Ext/DataStore>
Inherits Wt::WResource.
Public Member Functions | |
DataStore (WAbstractItemModel *model, DataLocation dataLocation, WObject *parent=0) | |
Create a new data store. | |
~DataStore () | |
Destructor. | |
void | addColumn (int columnIndex, const std::string &jsonName) |
Add a column to the list of columns to be serialized. | |
void | setFilterColumn (int columnIndex) |
Set the column which is used to handle filter requests. | |
Protected Member Functions | |
virtual void | handleRequest (const Http::Request &request, Http::Response &response) |
Handles a request. |
A resource that serializes data from a data model.
An instance of this class is used by ComboBox and TableView widgets to serialize data from a WAbstractItemModel. The data store can serialize data both for a ClientSide or ServerSide location of the data. When the location is ServerSide, the model supports transmission of certain data pages, and filtering of the model.
To use the data store, you need to specify which columns from the model need to be serialized.
Wt::Ext::DataStore::DataStore | ( | WAbstractItemModel * | model, | |
DataLocation | dataLocation, | |||
WObject * | parent = 0 | |||
) |
Create a new data store.
Data will be fecthed from model.
void Wt::Ext::DataStore::addColumn | ( | int | columnIndex, | |
const std::string & | jsonName | |||
) |
Add a column to the list of columns to be serialized.
The column columnIndex of the model is added to the current list of columns that are serialized. The jsonName provides the column label that is transmitted.
void Wt::Ext::DataStore::handleRequest | ( | const Http::Request & | request, | |
Http::Response & | response | |||
) | [protected, virtual] |
Handles a request.
Reimplement this method so that a proper response is generated for the given request. From the request
object you can access request parameters and whether the request is a continuation request. In the response
object, you should set the mime type and stream the output data.
A request may also concern a continuation, indicated in Http::Request::continuation(), in which case the next part for a previously created continuation should be served.
While handling a request, which may happen at any time together with event handling, the library makes sure that the resource is not being concurrently deleted, but multiple requests may happend simultaneously for a single resource.
Implements Wt::WResource.
void Wt::Ext::DataStore::setFilterColumn | ( | int | columnIndex | ) |
Set the column which is used to handle filter requests.
A request for filtering data will be done by matching the given filter against data in the model at column columnIndex.