From a212c951bb2154192ed1765fdd2da683b64f1774 Mon Sep 17 00:00:00 2001 From: Aleksey Novikov Date: Fri, 29 Sep 2023 17:10:10 +0300 Subject: [PATCH] #7036 Dynamic Matrix - rowTitleWidth does not work Fixes #7036 --- src/question_matrixdropdownrendered.ts | 5 ++- tests/question_matrixdynamictests.ts | 42 +++++++++++++++++++++++++- 2 files changed, 43 insertions(+), 4 deletions(-) diff --git a/src/question_matrixdropdownrendered.ts b/src/question_matrixdropdownrendered.ts index 64ebe8c612..88bc6c9505 100644 --- a/src/question_matrixdropdownrendered.ts +++ b/src/question_matrixdropdownrendered.ts @@ -678,9 +678,8 @@ export class QuestionMatrixDropdownRenderedTable extends Base { var renderedCell = this.createTextCell(row.locText); renderedCell.row = row; res.cells.push(renderedCell); - if (useAsHeader) { - this.setHeaderCellWidth(null, renderedCell); - } + this.setHeaderCellWidth(null, renderedCell); + renderedCell.className = new CssClassBuilder() .append(renderedCell.className) .append(this.cssClasses.rowTextCell) diff --git a/tests/question_matrixdynamictests.ts b/tests/question_matrixdynamictests.ts index e46ee42efd..21d1418a27 100644 --- a/tests/question_matrixdynamictests.ts +++ b/tests/question_matrixdynamictests.ts @@ -18,7 +18,7 @@ import { QuestionTextModel } from "../src/question_text"; import { SurveyElement } from "../src/survey-element"; import { Action } from "../src/actions/action"; import { MatrixDropdownColumn, matrixDropdownColumnTypes } from "../src/question_matrixdropdowncolumn"; -import { QuestionMatrixDropdownRenderedRow } from "../src/question_matrixdropdownrendered"; +import { QuestionMatrixDropdownRenderedErrorRow, QuestionMatrixDropdownRenderedRow } from "../src/question_matrixdropdownrendered"; export default QUnit.module("Survey_QuestionMatrixDynamic"); @@ -3533,6 +3533,46 @@ QUnit.test("matrix dropdown + renderedTable.rows", function (assert) { assert.equal(cells[3].cell.column.name, "col2", "row3.col2 correct column"); }); +QUnit.test("matrix dropdown + renderedTable.rows - title width", function (assert) { + var matrix = new QuestionMatrixDropdownModel("q1"); + matrix.addColumn("col1"); + matrix.columns[0].cellType = "text"; + matrix.addColumn("col2"); + matrix.rows = ["row1", "row2"]; + + var rows; + var cells; + rows = matrix.renderedTable.rows.filter(r => !(r instanceof QuestionMatrixDropdownRenderedErrorRow)); + + cells = matrix.renderedTable.headerRow.cells; + assert.equal(cells[0].width, "", "header row col1 width get from rowTitleWidth"); + assert.equal(cells[0].minWidth, "", "header row col1 min-width get from rowTitleWidth"); + + cells = rows[0].cells; + assert.equal(cells[0].width, "", "row 1 col1 width get from rowTitleWidth"); + assert.equal(cells[0].minWidth, "", "row 1 col1 min-width get from rowTitleWidth"); + + cells = rows[1].cells; + assert.equal(cells[0].width, "", "row 2 col1 width get from rowTitleWidth"); + assert.equal(cells[0].minWidth, "", "row 2 col1 min-width get from rowTitleWidth"); + + matrix.rowTitleWidth = "400px"; + rows = matrix.renderedTable.rows.filter(r => !(r instanceof QuestionMatrixDropdownRenderedErrorRow)); + + cells = matrix.renderedTable.headerRow.cells; + assert.equal(cells[0].width, "400px", "header row col1 width get from rowTitleWidth"); + assert.equal(cells[0].minWidth, "400px", "header row col1 min-width get from rowTitleWidth"); + + cells = rows[0].cells; + assert.equal(cells[0].width, "400px", "row 1 col1 width get from rowTitleWidth"); + assert.equal(cells[0].minWidth, "400px", "row 1 col1 min-width get from rowTitleWidth"); + + cells = rows[1].cells; + assert.equal(cells[0].width, "400px", "row 2 col1 width get from rowTitleWidth"); + assert.equal(cells[0].minWidth, "400px", "row 2 col1 min-width get from rowTitleWidth"); + +}); + QUnit.test("matrix dynamic + renderedTable.rows", function (assert) { var matrix = new QuestionMatrixDynamicModel("q1"); matrix.addColumn("col1");