Have an idea?

Visit Sawtooth Software Feedback to share your ideas on how we can improve our products.

Hidden any rows in grid

Dear All,

I have a  grid question, there are 5 rows.

Q1Row1 - Display score |1|2|3|4|5|
Q1Row2 - Display score |1|2|
Q1Row3 - Display score |1|2|3|4|5|
Q1Row4 - Display score |2|3|
Q1Row5 - Display score 1|2|3|4|5|

Is it possible?
asked Jan 21 by Saroeun Bronze (1,340 points)

1 Answer

+1 vote
 
Best answer
Try this:

<script>
$(document).ready(function(){
    removeGridCellContents('[% QuestionName() %]', 2, 3);
    removeGridCellContents('[% QuestionName() %]', 2, 4);
    removeGridCellContents('[% QuestionName() %]', 2, 5);
    removeGridCellContents('[% QuestionName() %]', 4, 1);
    removeGridCellContents('[% QuestionName() %]', 4, 4);
    removeGridCellContents('[% QuestionName() %]', 4, 5);
})

function removeGridCellContents(qname, r, c) {
    if ($('.mobile_grid').length) {
        $('#' + qname + '_r' + r + '_' + c + ',#' + qname + '_r' + r + '_c' + c).closest('.input_row').remove();
    }
    else {
        $('#' + qname + '_r' + r + '_' + c + ',#' + qname + '_r' + r + '_c' + c).closest('.input_cell')
            .removeClass('input_cell clickable')
            .css('cursor', 'default')
            .off('click').off('keyup')
            .empty();
    }
}
</script>
answered Jan 22 by Zachary Platinum Sawtooth Software, Inc. (69,875 points)
selected Jan 24 by Saroeun
Zachary,
I have tried but still not working.
Do you have anyway?
Here my script,

<script>
$(document).ready(function(){
    removeGridCellContents([% Q1Row2 %], 3, 5);
    removeGridCellContents([% Q1Row4 %], 1);
    removeGridCellContents([% Q1Row4 %], 3, 5);
})
 
function removeGridCellContents(qname, r, c) {
    if ($('.mobile_grid').length) {
        $('#' + qname + '_r' + r + '_' + c + ',#' + qname + '_r' + r + '_c' + c).closest('.input_row').remove();
    }
    else {
        $('#' + qname + '_r' + r + '_' + c + ',#' + qname + '_r' + r + '_c' + c).closest('.input_cell')
            .removeClass('input_cell clickable')
            .css('cursor', 'default')
            .off('click').off('keyup')
            .empty();
    }
}
</script>
Have you tried using the code as-is?  It should not require any changes to work for your problem.
Perfect, Thanks
Hi Zachary,

If I want to hide between 2 Grids number, is it possible?

Example:

If Q1Row1Col1=0 => Q2Row1Col1=hide
...