Hi. I have to dynamic panels (one contains inputs for collecting data, another for read-only expressions to show this data). I'm trying to write custom function to get the index of parent panel which is in dynamic panel and planning to use it in my expressions.
TypeScriptFunctionFactory.Instance.register('getParentPanelIndex', function (params: any[]) {
const result = params[0].parentQuestion.panels.indexOf(params[0].parent);
return result;
});
Thanks!
Hi Monika,
If you wish to use the first Dynamic Panel's input values to calculate expressions within the second Dynamic Panel, I may recommend that you use the
valueName
property as demonstrated in the following demo: Merge Question Values. SetvalueName
for both Dynamic Panel questions to the same value. Now, values which user enter to the first Dynamic Panel become available in a second Dynamic Panel question via the{panel.questionName}
reference. Also, you can access a panel index via the{panelIndex}
expression.Please consider the following example:
{ "logoPosition": "right", "pages": [ { "name": "page1", "elements": [ { "type": "paneldynamic", "name": "userInfoPanel", "title": "User Information", "valueName": "userInfo", "templateElements": [ { "type": "text", "name": "fName", "title": "First Name", "defaultValue": "Jane" }, { "type": "text", "name": "lName", "title": "Last Name", "defaultValue": "Doe" } ] }, { "type": "paneldynamic", "name": "summaryPanel", "valueName": "userInfo", "templateElements": [ { "type": "expression", "name": "summaryInfo", "expression": "'Panel # ' + {panelIndex} + ': ' + {panel.fName} + ' ' + {panel.lName}" } ] } ] } ] }
Let me know if this configuration works for you.
Thanks for your quick reply Jane. This configuration works with your example, however I still have issues with my own form (communicating between two dynamic panels don't work well when using 'valueName' in Angular), but I was informed by my colleague that there was a bug and you already fixed it and we are waiting for the new version release.
Hello Monika,
I suppose you may be talking about the following issue: When using valueName for a Panel Dynamic and Matrix, matrix cells appear empty in Angular. Yes, it was already fixed. We expect the next maintanance update to be available within a day or so.
Please stay tuned.