How To Create Compound Grids

Overview

The compound grids, is a loop of X questions which is shown as a grid instead of looping over the questions one by one. For example, you can display all the questions of an iteration as a grid. 

Steps:

1. Create a chapter that will hold different question types (Single Choice, Multiple Selection, Open Ended etc.)

2. Set the chapter to run in a loop. 

3. On the Loops tab we’ve added the new “Render as grid”:

Which will then render the loop as a grid with each question being a column and each row being a loop iteration:

Compound Grid Callback Function - OnRenderGridInit()

In order to pipe the function 'OnRenderGridInit() should be used as follows:

function OnRenderGridInit(inChapterIndex, ioParams){
 if(inChapterIndex==3) //Verifies that the chapter is chapter index 3 in the script
 {
 for(var i=1; i<=6; i++)
 {
  var IterationText = AnswerChoice(QRef(101),i);
  ioParams.Rows[i].Name = IterationText;
  }
 }
}

You can also use this function to set the alignment and other params for the Grid

function OnRenderGridInit(inChapterIndex, ioParams){
if (inChapterIndex == 3){ 
ioParams.CellAlignment = eRenderGridAlignment.Center;
ioParams.ColumnHeaderAlignment = eRenderGridAlignment.Top;
ioParams.RowHeaderAlignment = eRenderGridAlignment.Bottom;

ioParams.Columns[0].WidthPercentage = 10;
ioParams.Columns[1].WidthPercentage = 70;
ioParams.Columns[2].WidthPercentage = 20;
}
}

ioParams Available

  • Columns Parameters
    • WidthPercentage - will set the column width
    • ColumnHeaderAlignment - Will set the Column Alignment
      Values: Top/Bottom/Center
  • Rows Parameters
    • RowHeaderAlignment - Will set the Row Alignment
      Values: Top/Bottom/Center
  • Cell Parameters
    • CellAlignment - Will set the Cell Alignment
      Values: Top/Bottom/Center

 

IMPORTANT NOTE: Text piping to questions that are part of a compound grid:

Unlike text piping to "regular" questions (Click Here to learn about Text Piping), when done in a compound grid, the piping code should be placed in the loop chapter's start script (instead of in the question's start script). So for example, if I have question index 10 inside loop chapter index 5 that is a compound grid, and I want to pipe a text, "MyText" to that Q10, I'll write this code in the chapter's start script: SetTextFormat(QRef(10), "MyText");

 

 

In the attached example survey you would find a demonstration of the how to implement this type of logic. 

In order to test the sample, please follow this manual on how to import the survey to your studio - http://support.dooblo.net/entries/22388573-How-to-import-a-survey

That's It !

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

0 comments

Please sign in to leave a comment.