surveyjs / survey-analytics

Customizable JavaScript library to create interactive survey data dashboards and facilitate survey results analysis for your end-users.
https://surveyjs.io/dashboard/examples/plain-data
Other
99 stars 52 forks source link

Tabulator: The Comment box value replaces the Other option value in Checkboxes questions #403

Closed JaneSjs closed 8 months ago

JaneSjs commented 8 months ago

T17243 - A comment value replaces the Other option value https://surveyjs.answerdesk.io/internal/ticket/details/T17243


A checkbox has the Other and Comment options enabled. image

{
 "pages": [
  {
   "name": "Seite1",
   "elements": [
    {
     "type": "checkbox",
     "name": "Frage1",
     "title": "Q1",
     "showCommentArea": true,
     "commentText": "Comment",
     "choices": [
      "Item 1",
      "Item 2",
      "Item 3"
     ],
     "showOtherItem": true
    }
   ]
  }
 ],
 "showPreviewBeforeComplete": "showAnsweredQuestions",
 "widthMode": "responsive"
}

A survey response.

{
    "Frage1": [
        "Item 1",
        "Item 2",
        "Other Value"
    ],
    "Frage1-Comment": "Some comment here"
}

A table displays the Comment value in the Other column as well as in the Q1 column: image

andrewtelnov commented 8 months ago

@tsv2013 Please use public getStoreOthersAsComment(): boolean function in selectbase.

  public getStoreOthersAsComment(): boolean {
    if (this.isSettingDefaultValue) return false;
    if(this.showCommentArea) return false;
    return (
      this.storeOthersAsComment === true ||
      (this.storeOthersAsComment == "default" &&
        (this.survey != null ? this.survey.storeOthersAsComment : true)) ||
      (this.hasChoicesUrl && !this.choicesFromUrl)
    );
  }

Thank you, Andrew