我正在使用 dgrid/Grid 来定义表结构。我希望表格单元格显示多行文本。我想出了如何让单元格编辑器成为 TextArea。但是,我不清楚如何让渲染器也显示多行文本。我该如何做到这一点?这就是我所拥有的:
editor({label: "First Name", field: "first", sortable: false, editor: getCellEditor, editOn: "dblclick", dismissOnEnter: false})
“getCellEditor”是返回dijit/form/TextArea的辅助方法。双击单元格会产生一个多行文本区域。但是,当我完成编辑并离开单元格时,单元格文本将恢复为单行显示。这是整个网格定义:
function getCellEditor() {
return new TextArea();
}
// Create a new constructor by mixing in the components
var CustomGrid = declare([ Grid, Keyboard, Selection, ColumnSet, ColumnResizer, editor ]);
var grid = new CustomGrid({
columnSets: [
[
[
editor({label: "First Name", field: "first", sortable: false, editor: getCellEditor, editOn: "dblclick", dismissOnEnter: false})
]
],
[
[
editor({ label: "Last Name", field: "last", sortable: false, editor: getCellEditor, editOn: "dblclick", dismissOnEnter: false}),
editor({ label: "Age", field: "age", sortable: false, editor: getCellEditor, editOn: "dblclick", dismissOnEnter: false})
]
]
],
selectionMode: "single", // for Selection; only select a single row at a time
cellNavigation: true // for Keyboard; allow only row-level keyboard navigation
}, "grid");
这是我的第一个 JavaScript 问题,所以请原谅任何缺失/不充分的信息。如果您需要任何其他信息来回答此问题,请告诉我。