2024 Nov 07 3:09 PM - edited 2024 Nov 07 3:12 PM
In my MDK-Application on iPhone I want to hide and show controls dynamically by setting the visible property by a rule. For a few Controls it is not working, for example simpleProperty. If I add a rule to the "IsVisible" property the rule is not executed when I do a redraw. For other controls it is working as expected (for example ObjectCellItem)
Only when I navigate to the Page the rule for "IsVisible" is executed.
For testing I created a new MDK Project in BAS with the Base template. I added only
The redraw button has no effect (the rule for "IsVisible" is not executed). With navigation it is working.
Here is my code:
The three controls in Main.page
"Controls": [
{
"_Type": "Control.Type.FormCell.SimpleProperty",
"_Name": "FormCellSimpleProperty0",
"IsVisible": "/Test/Rules/visible.js",
"Separator": true,
"Caption": "Caption",
"PlaceHolder": "PlaceHolder",
"Enabled": true,
"IsEditable": true
},
{
"_Type": "Control.Type.FormCell.Button",
"_Name": "FormCellButton0",
"IsVisible": true,
"Separator": true,
"Title": "Redraw",
"Alignment": "Center",
"ButtonType": "Text",
"Semantic": "Tint",
"Image": "res://mdk_logo.png",
"ImagePosition": "Leading",
"Enabled": true,
"OnPress": "/Test/Rules/redraw.js"
},
{
"_Type": "Control.Type.FormCell.Button",
"_Name": "FormCellButton1",
"IsVisible": true,
"Separator": true,
"Title": "navigate",
"Alignment": "Center",
"ButtonType": "Text",
"Semantic": "Tint",
"Image": "res://mdk_logo.png",
"ImagePosition": "Leading",
"Enabled": true,
"OnPress": "/Test/Rules/navigate.js"
}
Rules/init.js
export default function init(clientAPI) {
clientAPI.getAppClientData().visible = true;
}
Rules/redraw.js
export default function redraw(clientAPI) {
clientAPI.getAppClientData().visible = !clientAPI.getAppClientData().visible
clientAPI.evaluateTargetPath("#Page:Main").redraw();
}
Rules/navigate.js
export default function navigate(clientAPI) {
return clientAPI.executeAction({
"Name": "/Test/Actions/GenericNavigation.action",
"Properties": {
"PageToOpen": "/Test/Pages/Main.page",
"clearHistory": true
}
});
}
Rules/visible.js
export default function visible(clientAPI) {
return clientAPI.getAppClientData().visible;
}
Tested with MDK-Client 24.7.0
Request clarification before answering.
This is an expected behavior. On Form Cell controls, a redraw does not fully recreate the control due to the fact that there may be data already entered in the control.
If you need to show / hide a form cell field you are probably better off getting the field and calling setVisible(false) on it. If you really want to recreate the form cell field you can get the field and call reset() on it to recreate / redraw which would trigger rule evaluation again for the Visible property. This will also clear any user input and revert back to the initial value for the field.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
74 | |
30 | |
9 | |
7 | |
7 | |
6 | |
6 | |
4 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.