Question T3884
Visible to All Users

Disable and clear checkboxes in matrix dynamic panel

created 5 years ago

Hello,

I'm trying to figure out how to disable and clear check boxes if a certain checkbox is selected. In my case I have a list and one option is "None". If the user selects "None" I would like to disable the other checkboxes and clear any that were previously selected. I've looked through the docs and through previous support tickets and I'm unsure how to accomplish this. Any help would be appreciated. Here is a plunkr with an example https://plnkr.co/edit/kojosg9TGkd6y996

Thank you,
Casey

Answers approved by surveyjs Support

created 5 years ago

Hello,
Here is the updated example.

Thank you,
Andrew
SurveyJS Team

    Comments (3)

      Thank you. This is helpful but if I add "hasNone: true" to one column in the matrix dynamic it only controls that column. I'd like to be able to control both columns with only one "None" checkbox. I was hoping there would be a way to listen for an event and do this programatically. When a checkbox is selected in the event if it's the "None" checkbox then clear all other checkboxes from both columns. Is there an event or a way to do this?

      Also is there a way to insert the "None" checkbox at the top of the list of checkboxes rather than the bottom. Looking at the source code it doesn't look like this is possible. If there were a prop for placement that would be great. Something like "hasNoneLocation" which would use unshift instead of push to add the None checkbox.

      I can get away without using a matrixdynamic panel for my use case. It seems I should be able to use a regular checkbox for "None" and the "isItemSelected" method and then the "toggleSelectAll" method to make this work somehow but not sure how.

      Thanks again for your help

        Hello,
        If you want to write some to implement this functionality in a custom way, then you need to use survey.onMatrixCellValueChanged event. Please review the options object parameter. It has everything you need, for example: options.getCellQuestion(columnName) will return you your checkbox question in the next column by column name.

        Thank you,
        Andrew
        SurveyJS Team

          Thank you for your help