Most of the edit actions (such as Edit User, Edit Usergroup, Edit UserAction) within the manager are built around the DataEditor concept from the very first version of Smartsite 7.x. In fact, even Edit Item is in it's core a DataEditor, although with a high level of customization.
Within this concept, there are two major building blocks: the metatype xml and the dataeditor xml.
And there's a third component: the instance xml, containing the record data.
Adding or editing a record is achieved by constructing the instance xml using the metatype.
The dataeditor xml combined with this instance is then converted to an XForm, which is the basis for all edit actions within the Smartsite manager.
When you have debugging enabled, you can view each of these components when you are within a DataEditor action.
The metatype xml defines the data: which table, which columns, relations to other tables, etc.
For each column, the metatype xml defines e.g. it's datatype, restrictions such as maxlength, whether or not the column is nillable, etc.
The dataeditor xml defines the UI: which fields (=columns) should be presented to the user and which edit control should be used for each field. Optionally, these fields can be grouped on different tabs. Further more, the dataeditor xml can also be used to define additional model logic, to e.g. validate and/or enforce constraints on the data.
Since the DataEditor concept within the manager is fully XForms based, the dataeditor xml is converted to a XForm document. So, any custom logic needed, must be written in XForms as well.
The instance xml contains the record data. It will exactly represent the meta type.
When adding a record, the metatype is used to generate an empty instance.
When saving a record, the metatype xml and the instance xml are both used as input to represent and describe the data to be saved.
Every edit action is accompanied by a library action, displaying the records within the underlying table.
The buttonbar on top gives access to add/edit and/or delete record(s).
And most of the libraries offer one or more facets to filter the records.
As of Smartsite 7.7, you can now build your own DataEditor action(s) to manage records within custom tables. All of the above mentioned building blocks and concepts will play a part when creating a custom DataEditor action.
Smartsite 7.7 include several classes which makes creating your own DataEditor quite easy. These (custom) DataEditors are managed using the DataEditors action, which also includes a wizard to create a DataEditor action from scratch.
A DataEditor action definition contains:
- The tablename.
- Code (a guid, which is used within the library action for your custom DataEditor action).
- Dataeditor xml, which defines the UI for adding/editing the records.
- Metatype xml, which describes the data.
- Library configuration, which contains the configuration for the library action (which columns to display, one or more facets, etc.)
- Implementation (C# code or a reference to a type), which can be used to e.g. write additional save logic.
Notice that some of the new actions within the Smartsite 7.7 manager (Access Types, AccessType Levels, Subtrees, Localized Strings, Userpaths, to name a few) are built using the same technique, the only difference is that the DataEditor definitions are included as embedded resource.