cancel
Showing results for 
Search instead for 
Did you mean: 

Redraw a MDK Dynamic Page

Angelo_Ab
Participant
0 Kudos
151

Hi, 

i have a MDK Dynamic Page that display Texts using FormCell Notes Controls.

This is the Rules for create the Page MedaData:

return clientAPI.read(servicePath, "TextIdVHSet", [], query).then((result) => {
        for (let i = 0; i < result.length; i++) {
            const control = {};
            let orderText = result.getItem(i);
            control["_Name"] = "FormCellNote" + i;
            control["_Type"] = "Control.Type.FormCell.Note";
            control["Caption"] = orderText.ID + " - " + orderText.Description;
            control["Enabled"] = true;
            control["IsEditable"] = true;
            control["IsVisible"] = true;
            control["PlaceHolder"] = "PlaceHolder";
            control["Separator"] = true;
            control["MinNumberOfLines"] = 3;
            control["MaxNumberOfLines"] = 10;
            PageMetaData.Controls[0].Sections[0].Controls[i] = control;
        }
        return PageMetaData;
    });

 This texts page, when app is opened, show a default list of Notes like this:

Angelo_Ab_0-1733272135256.png

After, with an user action(button), some calculated Texts should be added.

Unfortunately the Page MetaData Rules cannot trigger anymore.

I tried a page.redraw() inside the user Action but nothing happens.

How I can redraw the page trough an Action showing original text plus some calculated texts ?

Edit: The texts page is inside a tab of tabs page loaded this way:

Angelo_Ab_0-1733303832359.png

If I click the first time on the Tab with Text Page, the PageMetadata rule is called.

If I change tab and return in the Text Page tab, the PageMetadata rule is not called anymore.

Thank you.

 

View Entire Topic
bill_froelich
Product and Topic Expert
Product and Topic Expert

If you need to set some texts after the page is rendered you should get a reference to the correct control and call setValue on it to specify the text.  Once a page is displayed you cannot dynamically add additional controls to the page but can hide/show controls.  So the initial page generation should include all the controls (some may be initially hidden).  We do not provide any re-rendering the page capabilities without closing and reopening the page.

The risk with even using a redraw is that there could be data the user entered but has not saved that would be lost if the page is redrawn.  That is why I recommend you just populate the existing fields with new values if needed.

Angelo_Ab
Participant
0 Kudos

@bill_froelich

I think there are some issue when the Dynamic Page is inside a Tab of Tabs Page.

First of all, when I navigate from a normal page to a Tabs Page, the rule for the Dynamic Page creation is triggered.

Unfortunately if the Dynamic Page is inside a Tab that is not immediately showed, if the User does not click that Tab where the dynamic page is contained and I need to set some text for some controls of that page with a Rule during an Action, this is not possible because the controls of the page does not exist yet.

The evaluateTargetPath fails:

clientAPI.evaluateTargetPathForAPI("#Page:CreateSalesOrderHeaderTexts/#Control:SectionedTable0").getControls()

If the User click on the Tab where the dynamic page is contained, the Rule for the Dynamic Page creation is triggered again and the above evaluateTargetPath works fine.

The second issue is when I try to set controls before the Dynamic Page Tab click with this code: 

clientAPI.getPageProxy().getAppClientData().HeaderTexts.forEach((text) => {
    let targetPath = "";
    targetPath = "#Page:CreateSalesOrderHeaderTexts/#Control:FCNote_" + text.ID;
    if (clientAPI.evaluateTargetPathForAPI(targetPath) == undefined) {
        return;
    }
    clientAPI.evaluateTargetPathForAPI(targetPath).setValue(text.Value);
    clientAPI.evaluateTargetPathForAPI(targetPath).setEditable(text.Editable);
});

In this case the Rule for Dynamic Page creation, after Tab click, does no longer triggered and the page results completely blank.

The current workaround is to add this code on OnPress Event of the Tab. With this workaround the rule for the Dynamic Page creation is triggered correctly and the controls can be set correctly.

Why this happens ?