survey-creator icon indicating copy to clipboard operation
survey-creator copied to clipboard

Design Mode - Add an option to specify a panel title placeholder

Open JaneSjs opened this issue 7 months ago • 0 comments

T22684 - Panel Title Placeholder https://surveyjs.answerdesk.io/internal/ticket/details/T22684


View Demo

A panel's description placeholder is specified as follows:

Serializer.getProperty("panel", "description").placeholder = Enter panel description";

A panel's title placeholder cannot be specified using the Serializer API. It's necessary to use the following code.

const updateDefaultTitle = (panel) => {
    panel.locTitle.onGetTextCallback = (text) => {
      if (!text) {
        debugger;
        return "Enter Panel Title";
      }
      return text;
    };
    panel.locTitle.strChanged();
};

creator.onSurveyInstanceCreated.add((sender, options) => {
    if (options.area === "designer-tab") {
      options.survey.getAllPanels().forEach((q) => {
        updateDefaultTitle(q);
      });
      options.survey.onPanelAdded.add((sender, options) => {
        updateDefaultTitle(options.panel);
      });
    }
});

JaneSjs avatar Apr 04 '25 07:04 JaneSjs