Adjusting Matrix Column Widths | XM Community
Skip to main content
Question

Adjusting Matrix Column Widths

  • May 4, 2020
  • 7 replies
  • 524 views

I tried searching the community and not sure I saw a solution for this. I saw some workarounds, but not sure they would work in this instance. I'm also very new at this so sorry if this is a dumb question. I'm trying to make the columns more consistent in the matrix. I realize it's because my 1 and 10 have long text in them but this is pretty standard for our organization. I've shrunk the font down to an 8. I tried the "labels" that are native to the question type, but the right label extends over the N/A option, and that is inaccurate. Do I have other options here? Thanks for any feedback.
matrix columns.jpg

7 replies

TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • May 5, 2020

You can use labels and modify the colspan attribute with JS so the label doesn't extend over the NA.


  • Author
  • May 5, 2020

Thank you. That sounds like exactly what I need to do. I see that the colspan is 11 by default, so I would want to change it to 10. I don't really know much about JavaScript, other than copy and paste code that I found. Do you know what that code would look like?


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • May 6, 2020

Do you know what that code would look like?

var cl = jQuery("#"+this.questionId+" td.ColumnLabels");
cl.attr('colspan',cl.attr('colspan')-1);
EDIT: typo corrected


  • Author
  • May 6, 2020

Thanks for the prompt response. I tried this, and I didn't see any change. Maybe I input it wrong? I tried colspan-1 like you had and didn't see a change so I changed it to -4 just to see if the change was so minor I wasn't see it. Still no change. I tried it in addonload and addonready. When I preview the survey, I see that the ColumnLabels colspan is still set to 11. Did I implement incorrectly?

Qualtrics.SurveyEngine.addOnload(function()
{
var cl = jQuery("#"+this.questiondId+" td.ColumnLabels");
cl.attr('colspan',cl.attr('colspan')-4);
});


rondev
Level 6 ●●●●●●
Forum|alt.badge.img+22
  • Level 6 ●●●●●●
  • May 6, 2020

Incorrect spelling of this.questionId
Try changing to:
var cl = jQuery("#"+this.questionId+" td.ColumnLabels");
cl.attr('colspan',cl.attr('colspan')-4);


  • Author
  • May 6, 2020

that did it. Thanks so much. I should have caught that. Thank you both


  • October 30, 2020