1
如何保持水平滾動條不顯示?程序化dojox.grid.DataGrid上的水平滾動條
什麼,我嘗試的一個例子是在http://jsfiddle.net/fdlane/gjkGF/3/
下面是什麼,我試圖做的一個示範頁面。隨着容器div的寬度設置爲大於網格寬度,我期待水平滾動條不會顯示。
使用200px的當前高度和行數大於6的行,顯示垂直(良好)。但是,水平也顯示(壞)。
我錯過了什麼?
感謝
FDL
<!doctype html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/dojo/1.6/dijit/themes/tundra/tundra.css" />
<link rel="stylesheet" type="text/css" title="Style" href="http://ajax.googleapis.com/ajax/libs/dojo/1.6.1/dojox/grid/resources/Grid.css">
<link rel="stylesheet" type="text/css" title="Style" href="http://ajax.googleapis.com/ajax/libs/dojo/1.6.1/dojox/grid/resources/tundraGrid.css">
<title>Grid Scrolling</title>
</head>
<body class="tundra">
<div id="container" style="width: 350px; height: 200px">
<div id="myGrid">
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/dojo/1.6.1/dojo/dojo.xd.js"> </script>
<script>
dojo.require("dojo.store.Memory");
dojo.require("dojo.data.ObjectStore");
dojo.require("dojox.grid.DataGrid");
dojo.ready(function() {
var myStore = new dojo.store.Memory({
data: [{ id: "RecId1", values: "fooValue1" },
{ id: "RecId2", values: "fooValue2" },
{ id: "RecId3", values: "fooValue3" },
{ id: "RecId4", values: "fooValue4" },
{ id: "RecId5", values: "fooValue5" },
{ id: "RecId6", values: "fooValue6" },
{ id: "RecId7", values: "fooValue7" },
{ id: "RecId7", values: "fooValue7"}]
});
dataStore = new dojo.data.ObjectStore({
objectStore: myStore
});
var grid = new dojox.grid.DataGrid({
store: dataStore,
structure: [{
name: "ID",
field: "id",
width: "100px"
}, {
name: "Values",
field: "values",
width: "100px"
}]
}, "myGrid");
grid.startup();
});
</script>
</body>
</html>
謝謝。這工作。我只是以爲我創建的網格錯誤或調用啓動錯誤,因爲網格(大小)不應該有水平滾動。進一步的嘗試表明,如果將網格放在整頁邊框容器的中間窗格中,則在初始頁面加載時會顯示水平滾動,但隨後瀏覽器窗口的任何大小調整都會導致滾動消失。當然,這個嘗試是在我添加你推薦的風格之前完成的。必須與.resize()正在觸發時有關。再次感謝你的幫助。 fdl – fdlane
idd youre right,bordercontainer佈局在調整大小時調用其所有子級的大小 - 如果子級具有任何此類功能 – mschr
我只希望我瞭解如何使初始頁面加載時發生的大小調整正確隱藏水平滾動。加載頁面後觸發的大小調整然後用戶更改瀏覽器窗口確實會隱藏水平。 – fdlane