Data page can be used to expose CRUD data operations.Using a Data Page you can
- Expose data in different formats (XML, JSON, HTML, CSV…) using
- Insert or update records using
- Delete records using
|DataStructure||Data Structure the data will be based on.|
|Method||Optional method (filter) to be used for getting the data.|
|SortSet||Optional sort set using which the data will be sorted.|
Optional XSLT Transformation that will be used to transform the data returned by the data service using the DataStructure attribute.
If Transformation is omitted the result is the raw data as returned by the data service in a format depending on a specified MimeType:
If you want to provide data in another format you need to use the transformation to produce data in such a format. The above specified formats can be used without a transformation and data will be converted automatically.
When MimeType is application/json, please consider to define also TransformationOutputStructure.
|TransformationOutputStructure||A data structure where an output of the Transformation will be merged into. It's applied only when ResultXpath is not set and a MimeType field is set to application/json.If not defined, the final XML->JSON conversion after transformation works the following way: DataTypes - float, int, boolen, etc. are converted to string, attributes are prefixed with @. But if defined, conversion is DataSet->JSON conversion, which performs the standard way (as without transformation).|
In case you need a single value or only a subset of the produced data you can use an XPath expression to select only the data you need to return.
A string value of the resulting Xpath navigator ia used. It's mainly used for extracting pure text out of the result xml. If it's set and application/json mime-type is set too, then resulting JSON conversion is always done as a non-typed XML->JSON conversion (regardless of how Transformation and TransformationOutputStructure are set).
|AllowPUT||If set to True it will be possible to use a
|AllowDELETE||If set to True it will be possible to use a DELETE HTTP request to send data back to the API to be deleted from the database.|
A validation rule that will be called on the data loaded from the database before the data from input is merged into.
A validation rule that will be called after merging the data from a database with a data from input. This can be used for validating the resulting (updated) data before saving them in a database.
You will probably have the same validation rule set up as a state event anyway so any data access is always validated but you can assign the same rule here because it is cheaper to stop the web request if it is invalid than locking data in the database and validating them later in the process.
|LogTransformation||An XSLT transformation that will produce enhanced logging data. For details see How to set up an event logging with Log Transformations.|
If set to True and the MimeType is JSON the returned JSON string will not contain the root element converted from the XML representation (e.g. "ROOT").
It's applied only if a non-typed XML->JSON conversion is used (Transformation is given while TransformationOutputDatastructure is not)
When you want to send JSON or XML data back to the API in the HTTP request body you need to:
- Set AllowPUT to
- Add a new ParameterMapping under the Data Page API with any name and MappedParameter empty. This will pass the body to the API.
- Send the request under the same URL you used to load the data, e.g. /api/invoice/1234
It is recommended to set AllFields=True in the source data structure entities otherwise concurrency exceptions can occur.
The process then goes like this:
- When you send PUT request to
/api/invoice/1234first the old invoice no. 1234 is loaded from the database
- Then the data of the old invoice are updated with the data sent with the request
- Then the changes are saved to the database.
If you want to insert data you basically need to provide a parameter under which no invoice will be loaded, e.g.
/api/invoice/new. The first step which loads the record will find nothing resulting in INSERTs into the database.
Server has to be set to run all managed modules for all request, otherwise put operation will fail because of unauthorized access.
You can use built-in data pagination functions to return pages of data instead of whole lists. See LoadData Method for details.
You need to map the input parameters to the internal
_pageSize parameters the same way you would map other parameters. See Kendo Mobile - Pagination And Server Side Filtering for an example.
When you wan to send a request that will delete data you need to:
- Set AllowDELETE to True
- Send a request to the URL, e.g.
- The data will get loaded and then deleted.
As you see from the previous example there is no concurrency handling built-in and the last write wins.