Difference between revisions of "Add an extra column before an answer option column in single grid question"
(New page: == Challenge == In order to have extra space between an answer option column and others in single grid question As a questionnaire creator I want to add an extra empty column before a s...) |
|||
Line 1: | Line 1: | ||
− | == Challenge == | + | == Challenge == |
− | In order to have extra space between an answer option column and others in single grid question | + | In order to have extra space between an answer option column and others in single grid question |
− | As a questionnaire creator | + | As a questionnaire creator |
− | I want to add an extra empty column before a specific answer option column | + | I want to add an extra empty column before a specific answer option column |
− | '''Example''' | + | '''Example''' |
− | I have a single grid question like below. | + | I have a single grid question like below. |
− | [[Image: | + | [[Image:QuestionTips SingleGrid 1.jpg]] |
− | I want to separate Don't know column from others.<br>[[Image: | + | I want to separate Don't know column from others.<br>[[Image:QuestionTips SingleGrid 2.jpg]] |
+ | |||
+ | == Solution == | ||
+ | |||
+ | |||
+ | |||
+ | == Code == | ||
+ | <source lang="javascript" line="1"> | ||
+ | quest.addEmptyColumnBefore = function(answerOptionValue, cssClass) | ||
+ | { | ||
+ | //get the number of rows | ||
+ | var n = $(".grid_inner")[0].rows.length; | ||
+ | |||
+ | $("#grid_answeroption_text_" + answerOptionValue) | ||
+ | .before( | ||
+ | $("<td rowspan=\""+(n + 1)+"\"> </td>") | ||
+ | .addClass("grid_answeroption_text") | ||
+ | .addClass(cssClass) | ||
+ | ); | ||
+ | } | ||
+ | quest.onInit = function() | ||
+ | { | ||
+ | var dontKnow_value = 3; | ||
+ | |||
+ | this.addEmptyColumnBefore(dontKnow_value, "grid_space_cell"); | ||
+ | } | ||
+ | </source> |
Revision as of 09:56, 18 December 2008
Challenge
In order to have extra space between an answer option column and others in single grid question
As a questionnaire creator
I want to add an extra empty column before a specific answer option column
Example
I have a single grid question like below.
I want to separate Don't know column from others.
Solution
Code
1 quest.addEmptyColumnBefore = function(answerOptionValue, cssClass)
2 {
3 //get the number of rows
4 var n = $(".grid_inner")[0].rows.length;
5
6 $("#grid_answeroption_text_" + answerOptionValue)
7 .before(
8 $("<td rowspan=\""+(n + 1)+"\"> </td>")
9 .addClass("grid_answeroption_text")
10 .addClass(cssClass)
11 );
12 }
13 quest.onInit = function()
14 {
15 var dontKnow_value = 3;
16
17 this.addEmptyColumnBefore(dontKnow_value, "grid_space_cell");
18 }