cancel
Showing results for 
Search instead for 
Did you mean: 

On iPhone the redraw method is not working for all Controls

JonasX
Newcomer
0 Kudos
103

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

  • one simple property with a rule for "IsVisible"
  • one button for switching visibility and redrawing the page
  • one button for navigating to the same page.

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

View Entire Topic
bill_froelich
Product and Topic Expert
Product and Topic Expert
0 Kudos

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.