From 728e0e2b1a4846caa7dac7630c957c1ec2dc011b Mon Sep 17 00:00:00 2001 From: Andrew Telnov Date: Sat, 8 Jul 2023 15:16:18 +0300 Subject: [PATCH] Column width is not showing in property grid fix https://github.com/surveyjs/survey-creator/issues/4303 --- src/question_matrixdropdowncolumn.ts | 4 ++-- tests/question_matrixdropdownbasetests.ts | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/question_matrixdropdowncolumn.ts b/src/question_matrixdropdowncolumn.ts index 496fe9c44a..7e5fcc9110 100644 --- a/src/question_matrixdropdowncolumn.ts +++ b/src/question_matrixdropdowncolumn.ts @@ -393,10 +393,10 @@ export class MatrixDropdownColumn extends Base this.setPropertyValue("minWidth", val); } public get width(): string { - return this.getPropertyValue("width", ""); + return this.templateQuestion.width; } public set width(val: string) { - this.setPropertyValue("width", val); + this.templateQuestion.width = val; } public get colCount(): number { return this.getPropertyValue("colCount"); diff --git a/tests/question_matrixdropdownbasetests.ts b/tests/question_matrixdropdownbasetests.ts index 1c6460ea14..49d559e1c6 100644 --- a/tests/question_matrixdropdownbasetests.ts +++ b/tests/question_matrixdropdownbasetests.ts @@ -527,3 +527,18 @@ QUnit.test("survey.onPropertyValueChangedCallback on column property changed", f assert.equal(counter, 2, "callback called, #3"); assert.equal(propertyName, "expression", "expression is changed, #4"); }); +QUnit.test("Column width is not loaded, bug in Creator #4303", function (assert) { + const survey = new SurveyModel({ + elements: [ + { + type: "matrixdropdown", + name: "q1", + columns: [{ name: "col1", width: "222px" }], + rows: [0, 1, 2] + }, + ], + }); + const matrix = survey.getQuestionByName("q1"); + assert.equal(matrix.columns.length, 1, "There is one column"); + assert.equal(matrix.columns[0].width, "222px", "column width is loaded correctly"); +});