on 2023 Jul 21 8:41 AM
Hello MDK- Team and Experts,
I have noticed that if there is a button in a section of the MDK app which gets refreshed using redraw, when this button is pressed, the event handler added for OnPress is triggered multiple times. Any new redraw will add a new subscription to this event.
We are using MDK version 23.4 and we have this issue in several places. This affects the functionality of the apps. We need redraw so that the page reacts to changes of flags and the proper data is displayed in the page.
Any help/suggestions are highly appreciated.
Thank you,
Anca
Request clarification before answering.
Redrawing a page will not trigger the OnPress handler of a button. Can you please confirm the specific MDK 23.4.x version you are using? The latest version is MDK 23.4.2.
Can you provide more details on your scenario. Maybe attach the page metadata and assuming the OnPress is a rule the contents of that rule?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Redrawing a page/section does not trigger the onPress event but it registers it again. When you end up actually pressing the button, the event handler of that button will be called multiple times. The number of times it is called is increased after each redraw.
We are using MDK 23.4.2 version. Here is the code to a sample POC app created just to demonstrate this issue. The button from the footer of the section triggers the event handler only once but the one from the page footer triggers it multiple times.
Our issues are caused by the page redraw. In the meantime we were able to find some workarounds and not use it anymore but maybe in the future some feature will require an actual page redraw and we will face the same issues.
Here is a short gif demo: redrawissuedemo.gif
RedrawIssue.page
{
"Controls": [
{
"_Type": "Control.Type.SectionedTable",
"_Name": "RedrawIssuePageContent",
"Sections": [
{
"Separators": {
"TopSectionSeparator": false,
"BottomSectionSeparator": true,
"HeaderSeparator": true,
"FooterSeparator": true
},
"KeyAndValues": [
{
"Value": "{#Application/#ClientData/sText}",
"_Name": "KeyValue0",
"KeyName": "KeyName",
"Visible": true
}
],
"MaxItemCount": 1,
"_Type": "Section.Type.KeyValue",
"_Name": "RedrawIssueSectionKeyVal",
"Footer": {
"_Name": "SectionFooter0",
"Caption": "Press to trigger",
"Visible": true,
"OnPress": "/OrderProducts/Rules/RedrawIssues/TriggerOnPress.js",
"UseBottomPadding": false
},
"Visible": true,
"EmptySection": {
"FooterVisible": false
},
"Layout": {
"NumberOfColumns": 2
}
}
]
}
],
"_Type": "Page",
"_Name": "RedrawIssue",
"Caption": "RedrawIssue",
"PrefersLargeCaption": true,
"ToolBar": {
"Items": [
{
"_Type": "Control.Type.ToolbarItem",
"_Name": "ToolbarItem2",
"Caption": "Redraw",
"Enabled": true,
"Visible": true,
"Clickable": true,
"Style": "",
"OnPress": "/OrderProducts/Rules/RedrawIssues/RedrawOnPress.js"
},
{
"_Type": "Control.Type.ToolbarItem",
"_Name": "ToolbarItem3",
"Caption": "Trigger",
"Enabled": true,
"Visible": true,
"Clickable": true,
"Style": "",
"OnPress": "/OrderProducts/Rules/RedrawIssues/TriggerOnPress.js"
}
]
}
}
RedrawOnPress.js (rule)
export default function RedrawOnPress(clientAPI) {
const oPageProxy = clientAPI.getPageProxy();
// refresh page - duplicates the registration of the event handlers but is needed in some cases where
// based on certain action/flags entire sections should be displayed/hidden
oPageProxy.currentPage.redraw();
// refresh page content - does not create duplicate registration of the event handlers
oPageProxy.getControl("RedrawIssuePageContent").redraw();
// refresh section - does not create duplicate registration of the event handlers
oPageProxy.getControl("RedrawIssuePageContent").getSection("RedrawIssueSectionKeyVal").redraw();
}
TriggerOnPress.js (rule)
export default function TriggerOnPress(clientAPI) {
const oAppClientData = clientAPI.getAppClientData();
oAppClientData.sText += "+";
alert(oAppClientData.sText);
}
User | Count |
---|---|
73 | |
21 | |
9 | |
7 | |
6 | |
6 | |
4 | |
4 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.