Question T15124
Visible to All Users

After setting a value of type array to custom widget type of question it is showing question.value as [object,object]

created a year ago

Hi,

We are using custom widget in our application to which we need to append value of type of array of object. This was working fine earlier but after updating to latest version of Survey JS i.e. 1.9.112 we are seeing issue like instead of setting an actual array of object it is setting the value as [Object,Object]

What could be the reason for it?

Thanks,
Santosh

Comments (3)

    Hello Santosh,
    Would you share a problematic demo for research?

    Thanks

      Hi Jane,

      Thanks for your reply.

      Please find the attached reproducible sample application. This is not the exact replica of the custom widget we are using but we tried to reproduce the issue with minimum possible code.

      In this app, we are setting a value to custom widget question as an array but is gets assigned as [Object,Object]

      Thanks,
      Santosh

        Hello Santosh,
        Thank you for a demo. We may require some additional time to reply. Please stay tuned.

        Answers approved by surveyjs Support

        created a year ago

        Hello Santosh,
        It appears that a question.value is converted to string and appears as '[object Object]'. I see that you registered a new question class on top of a text question. If you wish to store an array within a question's value, I may suggest that you create a custom class on top of an empty class instead. The following code registers a new type using the empty question as the base.

        JavaScript
        activatedByChanged: function (activatedBy: any) { JsonObject.metaData.addClass('peoplepicker', [], (null) as any, 'empty'); }

        Now, a new question value appears as an array.
        Clipboard-File-1.png
        I updated your sample. Please check the attachment.

        Should you have any further questions, please let me know.

        Thanks