View Issue Details

This bug affects 1 person(s).
 36
IDProjectCategoryView StatusLast Update
13441Feature requestsSurvey takingpublic2021-03-10 17:21
Reporterorvil Assigned To 
PrioritynoneSeverity@60@ 
Status newResolutionopen 
Summary13441: Colums (still) can't be hidden in Array (numbers) questions
DescriptionRows can be hidden by using EM in Array questions. But although there are fields for editing an expressin - or simly 1 or 0 - there is no reaction when the question is displayed.
Steps To ReproduceCreate a Array (number) question and try to hide a culumn by setting the corresponding EM field to zero
Additional InformationIn the screenshot the two leftmost items should not be visible due to the zeros in the relevance equations
TagsNo tags attached.
Bug heat36

Relationships

has duplicate 12277 confirmed Bug reports Relevance equation on column of array-number question doesn't work 
has duplicate 15139 closedc_schmitz Feature requests Array by column relevance equation not working 
has duplicate 16992 new Bug reports QT_ SEMICOLON_ ARRAY_ MULTI_ FLEX_ Text problem: there is no problem hiding the whole row, but the whole column is invalid 
related to 13739 closeddominikvitt Bug reports Relevance equation broken for array by column 

Users monitoring this issue

User List jelo

Activities

orvil

orvil

2018-03-03 23:12

reporter  

Clipboard16.jpg (96,657 bytes)   
Clipboard16.jpg (96,657 bytes)   
c_schmitz

c_schmitz

2018-03-08 14:56

administrator   ~46948

Can you please attach a 2-question survey demonstrating the issue?
orvil

orvil

2018-03-09 22:48

reporter   ~47002

Here it is!
You can check it for a first impression at https://survey.asktom.cc/index.php/558933?newtest=Y
cdorin

cdorin

2019-06-24 11:06

manager   ~52496

@dominikvitt, this is the third one I found - this one is about Array (Numbers).
DenisChenu

DenisChenu

2019-08-08 12:23

developer   ~53151

@cdorin and @dominikvitt : it's a feature allowed for 4.0 ? If yes : i have some idea. Can be done in plugin or theme except for the admin part.

If you're OK : assing it to me , i think i can do it before november in core.
orvil

orvil

2019-09-25 12:35

reporter   ~53706

@DenisChenu: found a solution meanwhile by hiding columns via js (thanks to you addScript plugin!) and this idea you had for a former version of LS.
The js looks for cols with empty headers, sets these col to width 0 and recalculates the width of all other cols. Is working fine, as fas as I can see.

If you are on this issue I'd like to share the code working vor LS 3.18
DenisChenu

DenisChenu

2019-09-25 12:42

developer   ~53707

@orvil, i already have the javascript for 3.X , but need

1. Update admin GUI to add this option (on sub question)
2. Dynamically updated according to relevance:on / relevance:off event.
3. Work on IE10

I'm happy to have more code for the js part :)

Denis
c_schmitz

c_schmitz

2019-09-25 12:56

administrator   ~53708

Well, we don't have to have IE10 compatibility. See https://manual.limesurvey.org/Installation_-_LimeSurvey_CE#Browser_compatibility
orvil

orvil

2019-09-25 13:25

reporter   ~53709

@DenisChenu: Sounds promising, thats good news :)
added the js to hide working with LS 3.18.0 (its derived from your plugin version script. Had to change the css adressing, because former version did not work for me any more)

at 2. yes that's the crucial point I do not find how it is working
at 3. I definitely can say it does not work on ie11 - but unfortunately that's also true for the LS built in row-hiding on em expression!
hideEmptyColumns.js (2,607 bytes)   
// function to hide column(s) in array (number) with empty header
// remaining columns are stretched to original total width
// "table.questions-list" is default to find the input table -- may be this can be defined more accurate?
//
function hideEmptyColumns(tableIdentifyer = "table.questions-list") {
	
	$(tableIdentifyer).each(function(){
		var basetable=$(this);
		var i = 0;
		var p = 0;
		var hiddenPos = [];
		var remainPos = [];
		var oldWidth = [];
		var oldWidthPercentages = [];
		var sumRemainWidth = 0;
		var sumOldWidth = 0;
		var stretchFactor = 0;
		var dummy = "";

		// works with thead in LS 3.18 former version worked with col (why?)
		$(this).find("thead tr.ls-heading th").each(function(){
			
			// save the index of those cols that are to hide and those who remain visible => how to do with valudation?
			if($.trim($(this).html())===""){
				hiddenPos.push(i);
			} else {
				remainPos.push(i);
			}
			
			oldWidth.push($(this).width());			
			i = i + 1;			
		});

		// calculate the sum with of all cols as they are without shrink
		sumOldWidth  = oldWidth.reduce(function(a,b){ return a + b; });
		
		// recalculate the old *percentages* of all columns
		oldWidth.forEach(function(w){
		    oldWidthPercentages.push(w/sumOldWidth*100);
		});
		
		// calculate the sum width of only the remaining cols
		for (p of remainPos) {
			sumRemainWidth += oldWidth[p -1];
		}
		
		// calculate the stretch factor
		stretchFactor = sumOldWidth/sumRemainWidth;		
		
		// hide all columns with empty header but not col 1 
		for (p of hiddenPos) {
			i= p+1;   
			
			$(tableIdentifyer + " th:nth-child("+ i + ")").hide();
			$(tableIdentifyer + " td:nth-child("+ i + ")").hide();			
		}

		// refresh the column css width attributes, but let first column as it was
		dummy = "'" + oldWidthPercentages[0] + "%" + "'";
		$(tableIdentifyer + ' col:nth-child(0)').css({ 'width': dummy });
		
		// set hidden cols to 0%
		p = remainPos.length + 2; 
		for (i of hiddenPos) {
			
			$(tableIdentifyer + " col:nth-child(" + p + ")").css({ 'width': '0%' });		
			p = p + 1;			
		}
		
		// stretch visible cols, line title with original width first
		p = 0;
		i = 1;
		dummy = oldWidthPercentages[p]  + "%" ;
		$(tableIdentifyer + " col:nth-child(" + i + ")").css({ 'width': dummy });
		
		// now answer columns
		p = 2;
		for(i of remainPos) {
			
			dummy = oldWidthPercentages[i] * stretchFactor + "%";
			$(tableIdentifyer + " col:nth-child(" + p + ")").css({ 'width': dummy });
			
			p = p + 1;
		}

	});
}
hideEmptyColumns.js (2,607 bytes)   
DenisChenu

DenisChenu

2019-09-25 15:35

developer   ~53712

Right IE11 :) . And if column are not hidden but relevance is OK on «any browser» it's OK :).

Thanks for reminder @c_schmitz

About js : https://gitlab.com/SondagesPro/QuestionSettingsType/hideEmptyColumn/blob/master/assets/hideemptycolumn.js i think we can manage more easily with some data attribute in table too :). And usage of event https://github.com/LimeSurvey/LimeSurvey/blob/e838d95655a6e914e6d9bc0285104fe50b93f73f/assets/packages/limesurvey/survey.js#L59 allowing to test if it's a column or a line :)
orvil

orvil

2019-09-26 09:33

reporter   ~53715

@DenisChenu: Thanks, these are really nice pieces of code :) I'll check this out in my environment.
for what it's worth: IE 11 has a share of 3,76% (August 2019, worldwide) - hm?! https://de.statista.com/statistik/daten/studie/158095/umfrage/meistgenutzte-browser-im-internet-weltweit/
DenisChenu

DenisChenu

2020-03-02 16:00

developer   ~56275

giving up
ollehar

ollehar

2020-03-02 16:17

administrator   ~56277

> giving up

Close ticket?
DenisChenu

DenisChenu

2020-03-02 16:19

developer   ~56278

No, don't close ....

The issue still there. Maybe in Feature, not in bug ?

Issue History

Date Modified Username Field Change
2018-03-03 23:12 orvil New Issue
2018-03-03 23:12 orvil File Added: Clipboard16.jpg
2018-03-08 14:56 c_schmitz Assigned To => c_schmitz
2018-03-08 14:56 c_schmitz Status new => feedback
2018-03-08 14:56 c_schmitz Note Added: 46948
2018-03-09 22:48 orvil File Added: limesurvey_survey_issue13441.lss
2018-03-09 22:48 orvil Note Added: 47002
2018-03-09 22:48 orvil Status feedback => assigned
2018-03-29 08:08 DenisChenu Relationship added has duplicate 12277
2018-06-04 15:02 DenisChenu Relationship added related to 13739
2019-05-21 17:15 c_schmitz Product Version 3.1.x => 3.4.x
2019-06-24 11:06 cdorin Note Added: 52496
2019-08-08 12:21 DenisChenu Relationship added has duplicate 15139
2019-08-08 12:23 DenisChenu Note Added: 53151
2019-08-08 14:42 cdorin Assigned To c_schmitz => DenisChenu
2019-09-25 12:35 orvil Note Added: 53706
2019-09-25 12:42 DenisChenu Note Added: 53707
2019-09-25 12:56 c_schmitz Note Added: 53708
2019-09-25 13:25 orvil File Added: hideEmptyColumns.js
2019-09-25 13:25 orvil Note Added: 53709
2019-09-25 15:35 DenisChenu Note Added: 53712
2019-09-26 09:33 orvil Note Added: 53715
2019-10-25 14:37 jelo Issue Monitored: jelo
2020-03-02 16:00 DenisChenu Assigned To DenisChenu =>
2020-03-02 16:00 DenisChenu Status assigned => new
2020-03-02 16:00 DenisChenu Note Added: 56275
2020-03-02 16:17 ollehar Note Added: 56277
2020-03-02 16:19 DenisChenu Note Added: 56278
2021-01-20 08:27 DenisChenu Relationship added has duplicate 16992
2021-03-10 17:21 ollehar Project Bug reports => Feature requests