Question T11019
Visible to All Users

Matrix Dynamic with a Boolean column - Display only Yes or No value

created 2 years ago (modified 2 years ago)

[Ticket cloned from T11011: Is there a way to customize cell design in matrixdynamic ]

Hi Team,

I am trying to display survey form in "Display" mode.
Is there a way to customize cell in matrixdynamic questions?
I want to display only selected values in the cell of matrix when cellType is checkbox and boolean instead of all choices.

=> When CellType = boolean, show only Yes/No value in the cell. (Reference:Boolean.png, In Billable column, No (on row1) and Yes (on row2) should be displayed

Thanks,
Mahesh

Comments (2)

    Hello Mahesh,
    Would you please clarify how a single Yes/No value should be rendered?

      Hi Jane,

      Referring to Boolean.png attached on the ticket, i would like to render only 'No' text (on row1) and 'Yes' (on row2) on Billable column without toggle control in the cell.

      Answers approved by surveyjs Support

      created 2 years ago

      Hello Mahesh,
      Thank you for the clarification. The Boolean question in slider rendering mode cannot display just Yes or No options.
      If you wish to display the selected value only, I may suggest that you try the checkbox rendering mode for Boolean question.

      Set renderAs: "checkbox" for your Boolean cell and it will be rendered as a checkbox thus showing only Yes or No value:

      JSON
      ... { type: "paneldynamic", name: "question6", title: "Dynamic Panel", templateElements: [ { type: "matrixdynamic", name: "question7", title: "Dynamic Matrix within Panel", columns: [ { name: "Column 3", cellType: "boolean", renderAs: "checkbox" } ] } ] }

      Example

      Clipboard-File-1.png

      Please let me know if this works for you.

        Show previous comments (1)

          Hello,

          Is there a way to achieve this?

          Yes, you can implement your custom question renderer and set it for a question using the "renderAs" property.
          Sample can be found in our source code - https://github.com/surveyjs/survey-library/blob/master/src/knockout/components/boolean-checkbox/boolean-checkbox.ts (this code is for Knockout/jQuery libraries)

          Thanks, Serge
          SurveyJS Team

            Hello Serge,

            Thank you for your inputs.
            Is there sample source code for React? I tried to locate sample code in the repository, but could not find it.
            Appreciate if you can provide a source code link for react library or any codesandbox link.

              Hello,

              Here is the live example on our site - https://surveyjs.io/form-library/examples/questiontype-radiogroup-itemtemplate/reactjs#content-js

              Thanks, Serge
              SurveyJS Team