... | ... | @@ -28,6 +28,8 @@ Custom Forms and Controls: |
|
|
* [My custom form does not work](#my-custom-form-does-not-work)
|
|
|
* [How to create a UB enum control](#how-to-create-a-ub-enum-control)
|
|
|
|
|
|
Reports
|
|
|
* [Handle HTML report `onclick` event](#handle-html-report-onclick-event)
|
|
|
|
|
|
# Shell / Main Window
|
|
|
|
... | ... | @@ -492,4 +494,54 @@ In such a case, the following snipped should help to make the trick: |
|
|
|
|
|
`UB.core.UBEnumManager.getUBStore` function creates a request to get list of available enumeration options.
|
|
|
|
|
|
Notice the `UB.i18n('bpm_ProcessDefinition.engineType')` syntax. That is a shorthand syntax instead of `$App.domainInfo.entities['bpm_ProcessDefinition'].attributes['engineType'].caption` . |
|
|
\ No newline at end of file |
|
|
Notice the `UB.i18n('bpm_ProcessDefinition.engineType')` syntax. That is a shorthand syntax instead of `$App.domainInfo.entities['bpm_ProcessDefinition'].attributes['engineType'].caption` .
|
|
|
|
|
|
# Reports
|
|
|
|
|
|
## Handle HTML report onclick event
|
|
|
Starting from @unitybase/ubs>=4.1.19 report developer can define a `onclick` event for a `<a>` attributes. This feature is useful to open a form/grid/other report. There is some restriction for such cases:
|
|
|
- applicable only for HTML report
|
|
|
- `onclick` event can be defined only for `<a href="#" onclick="...">` html element - in all other html elements report editor/viewer will remove a `onclick` for security reason
|
|
|
- report viewer display a HTML report in iFrame, so to call something from `adminUI` API `window.parent.yourFunction` syntax must be used
|
|
|
- because of iFrame, `event` parameter for `onclick` do not passed ho handler, so all function parameters must be in-lined into HTML template
|
|
|
|
|
|
**Example:**
|
|
|
|
|
|
Consider our data is:
|
|
|
```
|
|
|
{ countries: [{ID: 10, name: 'Brasil'}, {ID: 20, name: 'Canada'}]}
|
|
|
```
|
|
|
and we want to display a Countries list and when used click on country - open a form to edit it.
|
|
|
|
|
|
In `Report builder` switch to `template` tab and open a HTML source (Tools->Source code)
|
|
|
Add a following template:
|
|
|
```
|
|
|
<table>
|
|
|
<!--{{#countries}}-->
|
|
|
<tr class="tinymce_templated" data-iterate-over="countries">
|
|
|
<td>
|
|
|
<a href="#" onclick="window.parent.openCountry({{ID}})">{{name}}</a></strong>
|
|
|
</td>
|
|
|
</tr>
|
|
|
<!--{{/countries}}-->
|
|
|
</table>
|
|
|
```
|
|
|
In `Code` tab change function `buildReport`:
|
|
|
|
|
|
```
|
|
|
buildReport: function(reportParams){
|
|
|
// this handler is used in template as onclick event
|
|
|
if (!window.openCountry) window.openCountry = function(ID){
|
|
|
// $App.doCommand({cmdType: 'showForm', entity: 'cdn_country', instanceID: ID})
|
|
|
$App.dialogInfo('You clicked on country with id ' + ID)
|
|
|
}
|
|
|
var data = {
|
|
|
countries: [{ID: 10, name: 'Brasil'}, {ID: 20, name: 'Canada'}]
|
|
|
}
|
|
|
var result = this.buildHTML(data)
|
|
|
return result
|
|
|
}
|
|
|
```
|
|
|
|
|
|
Press Test (html) button. On rendered report user can click on Country name and application perform action defined if `openCountry ` function.
|
|
|
|