Skip to content

Commit

Permalink
Special values dont have labels in matrix questions fix #8279 (#8281)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewtelnov committed May 15, 2024
1 parent 6800676 commit 9510c47
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/question_matrixdropdownrendered.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1044,7 +1044,7 @@ export class QuestionMatrixDropdownRenderedTable extends Base {
private getMultipleColumnChoices(column: MatrixDropdownColumn): any {
var choices = column.templateQuestion.choices;
if (!!choices && Array.isArray(choices) && choices.length == 0)
return this.matrix.choices;
return [].concat(this.matrix.choices, column.getVisibleMultipleChoices());
choices = column.getVisibleMultipleChoices();
if (!choices || !Array.isArray(choices)) return null;
return choices;
Expand Down
58 changes: 58 additions & 0 deletions tests/question_matrixdynamictests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4711,6 +4711,64 @@ QUnit.test("showInMultipleColumns and hasOther properties", function (assert) {
cell.question.comment = "";
assert.notOk(matrix.value, "Reset comment value");
});
QUnit.test("showInMultipleColumns and showNoneItem property", function (assert) {
const survey = new SurveyModel({
elements: [
{
type: "matrixdropdown",
name: "matrix",
columns: [
{
name: "col1",
cellType: "checkbox",
showInMultipleColumns: true,
showNoneItem: true,
noneText: "None abc",
choices: [1, 2, 3]
},
{ name: "col2", cellType: "comment" }
],
rows: ["row1", "row2"],
},
],
});
const matrix = <QuestionMatrixDropdownModel>survey.getQuestionByName("matrix");
assert.equal(matrix.renderedTable.headerRow.cells.length, 1 + 3 + 1 + 1, "header: row value + 3 choices + none item + one column");
assert.equal(matrix.renderedTable.rows[1].cells.length, 1 + 3 + 1 + 1, "first row: row value + 3 choices + none item + one column");
assert.equal(matrix.renderedTable.headerRow.cells[4].locTitle.text, "None abc", "Column text is correct");
const cell = matrix.renderedTable.rows[1].cells[4];
assert.equal(cell.question.getType(), "checkbox", "question is checkbox");
assert.equal(cell.question.showNoneItem, true, "showNoneItem is set");
});
QUnit.test("showInMultipleColumns and showNoneItem property properties & choices from question Bug#8279", function (assert) {
const survey = new SurveyModel({
elements: [
{
type: "matrixdropdown",
name: "matrix",
columns: [
{
name: "col1",
cellType: "checkbox",
showInMultipleColumns: true,
showNoneItem: true,
noneText: "None abc"
},
{ name: "col2", cellType: "comment" }
],
choices: [1, 2, 3],
rows: ["row1", "row2"]
},
],
});
const matrix = <QuestionMatrixDropdownModel>survey.getQuestionByName("matrix");
assert.equal(matrix.renderedTable.headerRow.cells.length, 1 + 3 + 1 + 1, "header: row value + 3 choices + none item + one column");
assert.equal(matrix.renderedTable.rows[1].cells.length, 1 + 3 + 1 + 1, "first row: row value + 3 choices + none item + one column");
assert.equal(matrix.renderedTable.headerRow.cells[4].locTitle.text, "None abc", "Column text is correct");
const cell = matrix.renderedTable.rows[1].cells[4];
assert.equal(cell.question.getType(), "checkbox", "question is checkbox");
assert.equal(cell.question.showNoneItem, true, "showNoneItem is set");
});
QUnit.test("showInMultipleColumns and hasOther properties, change in run-time", function (assert) {
const survey = new SurveyModel({
elements: [
Expand Down

0 comments on commit 9510c47

Please sign in to comment.