我的解決方案不使用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做例子。看到我的回答如下 –