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");