我的解决方案不使用dgrid/OnDemandGrid,但仍然有效。
1 /放网格在容器这样的:
<div id="container">
<div id="grid" style="width:100%;height:100%"></div>
</div>
2 /设定宽度,高度和在CSS滚动:
#container{
height: 200px;
width: 800px;
overflow: auto;
}
3 /在网格的结构放元件 “宽度” 为 “自动”:
var gridLayout = [
{
defaultCell: { width: 8, editable: false, type: cells._Widget, styles: 'text-align: right;' },
cells: [
{ name: "ID" , field: "id" , width: "auto" },
{ name: "Reg." , field: "reg" , width: "auto", editable: true },
{ name: "Type" , field: "type" , width: "auto" }
];
(例如)
行的大小足以显示其最大内容,div容器将滚动。
希望它会有所帮助。
这可以用dgrid做例子。看到我的回答如下 –