Question T17597
Visible to All Users

Changing panelAddText with onPropertyChanged

created 9 months ago

Im wanting to provide my clients the ability to change the Add Panel Text. Ive added a property to the property grid but cant seem to target the panel question in the onPropertyChanged cycle. Any help would be appreciated. Here is my JSON.

Code
questionJSON: { type: "paneldynamic", name: "Multiple Profile Search", title: "Multiple Profile Search", titleLocation: "hidden", templateElements: [ { name: "profile_search", type: "profile_search", }, ], },

this doesnt work…

Code
onPropertyChanged: async ( question: Question & any, propertyName: string, newValue: any, ) => { const survey = question.getSurvey(); survey?.getAllQuestions().forEach((q: any) => { if (q.getType() === "paneldynamic") { q.panels.forEach((panel: any) => { panel.elements.forEach((element: any) => { if (element.getType() === "panel") { element.panelAddText = newValue; } }); }); } }); if (propertyName == "Change Panel Add Text") { if (question.getType() === custom_question_multiple_profile_search) { const panel = survey.getPanelByName("Multiple Profile Search"); if (panel) { panel.panelAddText = newValue; } } } //void },

Answers approved by surveyjs Support

created 9 months ago (modified 9 months ago)

Hello Alex,
If you wish to allow users to change the panelAddText property of an inner Dynamic Panel element, configure an array of properties inherited from a source element (Dynamic Panel) using the inheritBaseProps attribute and list the panelAddText property name. Consider the following specialized component definition:

JavaScript
import { ComponentCollection } from "survey-core"; ComponentCollection.Instance.add({ name: "custompanel", inheritBaseProps: ["panelAddText"], questionJSON: { type: "paneldynamic", name: "Multiple Profile Search", title: "Multiple Profile Search", titleLocation: "hidden", templateElements: [ { name: "profile_search", type: "profile_search", }, ], } })

The "Add Panel" button text property will be available for a custom component:
Clipboard-File-1.png

Please let me know if you have further questions.

    Show previous comments (4)

      this is a custom component. im adding it to the collection at the bottom of the file. what are you doing differently in your example?

        Nevermind. That was it! Thanks for your help Jane!!

          No problem! Please feel free to contact us if you require further assistance.

          Thanks