我的解决方案不使用 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/ 在你的网格结构中将元素“width”设置为“auto”:
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 容器将具有滚动。
希望它会有所帮助。