- Posts: 54
- Thank you received: 1
Ask the community, share ideas, and connect with other LimeSurvey users!
Yes, you could probably do that but, since the array is mandatory, you would probably have to add an "N/A" column that would be clicked if a row is hidden;maybe i can filter the grid manually with some js?
<script type="text/javascript" charset="utf-8"> $(document).ready(function(){ // Identify the questions var thisQuestion = $('#question{QID}'); var hiddenQuestion = $(thisQuestion).prevAll('.multiple-opt:eq(0)'); var thisQID = $(thisQuestion).attr('id').replace(/question/, ''); var hiddenQID = $(hiddenQuestion).attr('id').replace(/question/, ''); // Hide the filtering question hiddenQuestion.hide(); // Remove extra array headers $('table.subquestion-list tbody:first', thisQuestion).append($('tr.answers-list', thisQuestion)); $('table.subquestion-list tbody:gt(0)', thisQuestion).remove(); // Loop through all answer rows and assign fake "relevance" $('tr.answers-list', thisQuestion).each(function(i) { var thisCode = $(this).attr('id').split('X'+thisQID)[1]; var hiddenValue = $('input.checkbox[id$="X'+hiddenQID+thisCode+'"]', hiddenQuestion).prop('checked'); $(this).attr('data-relevance', hiddenValue); }); // Hide the "N/A" column $('table.subquestion-list tr > *:last-child, col:last', thisQuestion).addClass('na').hide(); var answersWidth = (($('table.subquestion-list', thisQuestion).width()-$('th.answertext:first', thisQuestion).width())/$('table.subquestion-list', thisQuestion).width())*100; var answersCount = $('tr.answers-list:first td.answer-item:not(.na)', thisQuestion).length; var answerColWidth = answersWidth/answersCount; $('col:not(.col-answers):not(.na)', thisQuestion).css('width', answerColWidth+'%'); $('col.na', thisQuestion).css('width', '0%'); // Click "N/A" in all "non-relevant" rows $('tr.answers-list td.na input.radio', thisQuestion).prop('checked', false); $('tr.answers-list[data-relevance="false"] td.na input.radio', thisQuestion).trigger('click'); // Hide all "non-relevant" rows $('tr.answers-list[data-relevance="false"]', thisQuestion).hide(); }); </script>