Skip to content

Commit

Permalink
#7036 Dynamic Matrix - rowTitleWidth does not work
Browse files Browse the repository at this point in the history
Fixes #7036
  • Loading branch information
novikov82 committed Sep 29, 2023
1 parent 29cf60c commit a212c95
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 4 deletions.
5 changes: 2 additions & 3 deletions src/question_matrixdropdownrendered.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
42 changes: 41 additions & 1 deletion tests/question_matrixdynamictests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit a212c95

Please sign in to comment.