question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

The following question is about sharing values in two 'matrix dynamic' and setting up a 'default value'

See original GitHub issue

Are you requesting a feature, reporting a bug or asking a question?

  • Asking questions

What is the current behavior?

  • I’m trying to share the values between each matrix dynamic. On the website, however, examples are given of ‘matrix dynamic’ and ‘panel dynamic’ questions. Based on the previous response, in the below codes, only titles selected as ‘Yes’ on the next page are included.
  • In case of ‘defaultValue’ in first ‘matrix dynamic’ under 'surveyQuestions ', I am confused as to how to integrate data/objects from API with surveyQuestions JSON. If I grab the data ‘initialData’ 'from API like this, how do I integrate with ‘defualtValue’?
const intialData = [
            {
             title: 'TestTitle3 ',             
             description:
                'This is test value3.',           
            },   
           {
             title: 'TestTitle4',             
             description:
                'This is test value4.',           
            },                  
          ],          

Could you please guide me through these questions?

export const surveyQuestions = {
  pages: [
    {
      name: 'Test Matching',
      elements: [       
        {
          type: 'matrixdynamic',
          name: 'matrix_1',
          valueName: 'sharedList',
          defaultValue: [
            {
             title: 'TestTitle1 ',             
             description:
                'This is test value1.',           
            },   
           {
             title: 'TestTitle2',             
             description:
                'This is test value2.',           
            },                  
          ],          
          columns: [
            {
              name: 'title',
              title: Title',
              cellType: 'text',
              readOnly: true,
            },           
            {
              name: 'description',
              title: 'Description',
              cellType: 'comment',
              readOnly: true,
            },    
           {
              name: 'match',
              title: 'Is title match with your title (Y/N)',
              cellType: 'dropdown',
            },      
          ],
          choices: [
            {
              value: 'Yes',
              text: 'Yes',
            },
            {
              value: 'No',
              text: 'No',
            },
          ],
          rowCount: 2,
        },
      ],
    },
    {
      name: 'Shared Input',
      elements: [
        {
          type: 'matrixdynamic',
          name: 'question1',
          valueName: 'sharedList',
          defaultValue:[
          {
              "shared_title": "{sharedList.title}" <-------- this value is shown in the columns
           }
          ],
          columns: [
            {
              name: 'shared_title', // <------------------ Rows with titles matching 'Yes' in sharedList are need to be displayed
              title: 'Title',
              cellType: 'text',
              readOnly: true,
            },           
            {
              name: 'details',
              title: 'Other Details',
              cellType: 'comment',
            },
          ],        
          rowCount: 0,
        },
      ],
      title:
        'Input the detail.',
    },
  ],
  showQuestionNumbers: 'off',
};

What is the expected behavior?

  • Sharing values in two ‘matrix dynamic’.
  • Integrating data with 'surveyQuestions ’

How would you reproduce the current behavior (if this is a bug)?

Provide the test code and the tested page URL (if applicable)

Tested page URL:

Test code

your_code_here

Specify your

  • browser: Firefox
  • browser version: 92.0.1
  • surveyjs platform (angular or react or jquery or knockout or vue): react
  • surveyjs version: 17.0.2

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
andrewtelnovcommented, Oct 8, 2021

@iyamusms There are several errors in your code. The main one, you can’t use the shared data for your questions, because these questions have different data now. It means you have to stop using same valueName for them. The second, you need to get one question and not the list, survey.getQuestionByName() instead of “getQuestionsByValueName”. This function returns the list of questions with valueName. You are setting value property to an array. Here is the updated example.

Thank you, Andrew

1reaction
andrewtelnovcommented, Oct 8, 2021

@iyamusms It is not a shared data then. You should have two matrices with different value for each. You can handle survey.onValueChanged event and on changing value in the first matrix, change the value in the second matrix accordingly.

Thank you, Andrew

Read more comments on GitHub >

github_iconTop Results From Across the Web

Matrix Table Question - Qualtrics
About Matrix Table Questions. Matrix table questions allow you to combine multiple questions with the same answers. This is most useful when you...
Read more >
How do you dynamically allocate a matrix? - Stack Overflow
I just want to point out that a) array of arrays is not only solution, b) some operations are more easier to implement...
Read more >
Default Array Values in Java - GeeksforGeeks
Below are the default assigned values. S. No. Datatype, Default Value. 1, boolean, false. 2, int ...
Read more >
Video: Create a PivotTable manually - Microsoft Support
Create a manual PivotTable if you prefer to design the PivotTable yourself. Here's how. Want more? Create a PivotTable to analyze external data....
Read more >
Create and manage relationships in Power BI Desktop
If you query two or more tables at the same time, when the data is loaded, Power BI ... However, you can change...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found