Hiding table column (header)

More
3 years 3 months ago - 3 years 3 months ago #107404 by blacknail
blacknail created the topic: Hiding table column (header)
Hello all again,

I'm wondering how can I hide a column in an array question (in this case, the first one, which corresponds to the subquestions' column - please see attached screenshot). Since I want that column to be hidden AND to not take up any space, hiding the columns' borders is not an option. I've tried two different paths, both aren't working:

1) First, I've tried to use the "display:none;" property/value:
<script charset="utf-8" script="" type="text/javascript">
    $(document).ready(function ()
    {
        $("table.question thead td").css("display", "none");
        $("table.question tbody th").css("display", "none");
    });
</script>

The result, however, is that the entire table disappears, instead of the first column.

2) Then, I've tried also a solution found here :
<script charset="utf-8" script="" type="text/javascript">
$(document).ready(function ()
    {
        // Hide the first column
        $('#question'+qID+' th.header_answer_text, #question'+qID+' th.answertext').hide();
    });
</script>

Here, the result is that (apparently) nothing happens, and so the table doesn't change.

(I'm using Version 2.05+ Build 140320)

What can I be possibly doing wrong?

Best regards.



Attachments:
Last Edit: 3 years 3 months ago by blacknail. Reason: missing version number

Please Log in to join the conversation.

More
3 years 3 months ago #107407 by tpartner
tpartner replied the topic: Hiding table column (header)
You may have another table with class "question" in your template.

To be more specific, try this in the array question source:
<script type="text/javascript" charset="utf-8">	
 
	$(document).ready(function() {
 
		// Identify this question
		var thisQuestion = $('#question'+{QID}+'');
 
		$('table.subquestions-list thead td', thisQuestion).hide();   
		$('table.subquestions-list tr.answers-list th', thisQuestion).hide();   
		$('table.subquestions-list col', thisQuestion).css('width', 'auto');
	});
</script>


.

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: blacknail

Please Log in to join the conversation.

More
3 years 3 months ago #107408 by tpartner
tpartner replied the topic: Hiding table column (header)
Or better yet, here's a column-specific approach:
<script type="text/javascript" charset="utf-8">	
 
	$(document).ready(function() { 
 
		// Identify this question
		var thisQuestion = $('#question'+{QID}+'');
 
		// Add some column-specific classes
		$('table.subquestions-list tr', thisQuestion).each(function(i){
			$('> *', this).each(function(i){
				$(this).addClass('column-'+(i+1));
			});
		});
 
		// Hide all column-1 elements
		$('.column-1', thisQuestion).hide();   
		$('table.subquestions-list col', thisQuestion).css('width', 'auto');
 
	});
</script>

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: blacknail

Please Log in to join the conversation.

More
3 years 3 months ago #107409 by david2013
david2013 replied the topic: Hiding table column (header)
In advance setting, set the first column width to 0
The following user(s) said Thank You: blacknail

Please Log in to join the conversation.

More
3 years 3 months ago #107410 by tpartner
tpartner replied the topic: Hiding table column (header)
Yeah, good tip rot the first column David.

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: blacknail

Please Log in to join the conversation.

More
3 years 3 months ago #107440 by blacknail
blacknail replied the topic: Hiding table column (header)
Thanks for your quick and kind answers, tpartner and David. Both tparner's suggestions produced the same result: they indeed hid the first column, but the second one (which is now the first one viisible), got it's width messed up, just like the last one (please see the attached screenshot, "preocupacao_ambiental_3.png"). I looked at the code but couldn't find something "suspicious" that could led to this results - maybe previous changes made by myself to the template?

Concerning David's solution, it produced the result portraited in the "preocupacao_ambiental_2.png" screenshot (also attached to this post), i.e. it reduced dramatically the width of the first column, although it is still present there.

So, if you can find something that I can improve in (at least) one of tpartner's solutions, it would be great. Otherwise, I will take David's advice and just hide the first column borders, and it will suffice.

Thanks again for all your helpful comments.




Attachments:

Please Log in to join the conversation.

Did you already participate in our customer survey?

Don't miss your chance for great prices.

Please click here to participate:

Start now

Start now!

Just create your account and start using Limesurvey today.

Register now