Question T15647
Visible to All Users

custom property of type 'restfull'

created a year ago

We generate a composite question, named compoQuestion, which encompasses four types of questions (boolean, drop-down, comment, and file-upload). As a standard practice, when we intend to manage the properties of these four questions, we must initially incorporate those properties into the properties list of compoQuestion. Subsequently, when any property undergoes a change, we propagate that change to the respective target question. This process works seamlessly for most property types, such as strings, booleans, and choices.
However, a particular question arises regarding how to control the choicesByUrl property specifically for the drop-down question. How do we integrate choicesByUrl into compoQuestion and subsequently propagate the effect to the drop-down question?

adding custom property to compoQuestion like

JSON
const propertyInfo = { name:`choicesByUrl`, displayName: `choicesByUrl`, type: "restfull", className: "ChoicesRestful", onGetValue: function (surveyElement: { choicesByUrl: ChoicesRestful; }) { return surveyElement.choicesByUrl.getData() ; }, onSetValue: function (surveyElement: { setPropertyValue: (arg0: string, arg1: any) => void; }, value: any) { surveyElement.setPropertyValue("choicesByUrl", value); }, category: "choicesByUrl" };

cause a lot of error.

Any suggestions?

Comments (1)

    Hello Belal,
    I may need additional time to consider a possible option. Please stay tuned.

    Answers approved by surveyjs Support

    created a year ago

    Hello Belal,
    You can register a choicesByUrl property for a custom question as follows:

    JavaScript
    import { Serializer } from "survey-core"; Serializer.addProperty("country", { name: "choicesByUrl:restfull", className: "choicesByUrl", category: "choicesByUrl", onGetValue: (obj) => { return obj.contentQuestion.choicesByUrl; }, onSetValue: (obj, val) => { obj.contentQuestion.choicesByUrl.setData(val); }, });

    View CodeSandbox

    You can see that I use the contentQuestion object which is a Dropdown question instance and use its choicesByUrl property.

    Please let me know if this code works for you.

    Thanks