0

I'm working in SurveyJS, specifically in survey-creator. I want to create a custom class that extends panelmodel, but when trying to add it to survey-creator, it gives the error Uncaught (in promise) TypeError: e.isDefaultRendering is not a function

const creatorOptions = {
  showLogicTab: true,
  isAutoSave: true,
};


const creator = new SurveyCreator.SurveyCreator(creatorOptions);

class MyCustomClass extends Survey.Question {
  getType() {
    return "my-custom-class";
  }
  get myCustomProperty() {
    return this.getPropertyValue("myCustomProperty");
  }
  set myCustomProperty(val) {
    this.setPropertyValue("myCustomProperty", val);
  }
}

Survey.ElementFactory.Instance.registerElement("my-custom-class", (name) => {
  return new MyCustomClass(name);
});

Survey.Serializer.addClass(
  "my-custom-class",
  [{
    name: "myCustomProperty",
    category: "general",
    visibleIndex: 2
  }],
  function () {
    return new MyCustomClass("");
  },
  "question"
);

creator.toolbox.addItem({
  name: "my-custom-class",      // mismo que getType()
  title: "question Personalizado", 
  iconName: "icon-panel",     // nombre del icono (debe existir o ser uno genérico)
  json: {
    type: "my-custom-class",
    name: "panelPersonalizado1",
    elements: []
  },
  isCopied: true              // para que se arrastre/copiar al survey
});

creator.render("surveyCreatorContainer");
1
  • Unfortunately, it's impossible to extend a panel. Would you elaborate on your ultimate goal? Do you wish to add custom logic / rendering to a custom panel? Commented Aug 18 at 15:22

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.