2013-10-23 27 views
0

我想在頁面中使用DOJO邊框容器。我有這個樣本。在DOJO邊框容器中創建列

<script> 
     require(["dijit/layout/BorderContainer", "dijit/layout/ContentPane","dojo/domReady!"], 
     function(BorderContainer, ContentPane){ 
     // create a BorderContainer as the top widget in the hierarchy 
     var bc = new BorderContainer({ 
     style: "height: 300px; width: 500px;" 
     }); 

// create a ContentPane as the center pane in the BorderContainer 
var cp2 = new ContentPane({ 
    region: "center", 
    content: "how are you?,this is a test content" 
}); 
bc.addChild(cp2); 

// put the top level widget into the document, and then call startup() 
bc.placeAt(document.body); 
bc.startup(); 
}); 
</script> 

我想創建一些列,使它看起來像一個表。我怎樣才能做到這一點?? 有人可以幫助我

+0

BorderContainer不起作用。看例子。你看起來像一張桌子,你究竟明白了什麼? –

+0

我想要2-3列和10行。 – Bittu

回答

1

根據你的標題,(重點煤礦)「在道場使用BorderContainer創建列」,那麼我會覺得dgridtable container,或邊框容器內grid container配不配,這取決於你試圖用桌子來完成。

如果該表用於數據,請考慮dgrid。如果表格用於表單佈局,請考慮表格容器。如果表格用於小部件佈局,請考慮網格容器。

下面是一個使用網格容器的例子。 nbZones是列數。

<!DOCTYPE html> 
<html> 
    <head> 
     <link href='//ajax.googleapis.com/ajax/libs/dojo/1.9.1/dijit/themes/claro/claro.css' rel='stylesheet' type='text/css' /> 
     <link href='//ajax.googleapis.com/ajax/libs/dojo/1.9.1/dojox/widget/Portlet/Portlet.css' rel='stylesheet' type='text/css' /> 
     <link href='//ajax.googleapis.com/ajax/libs/dojo/1.9.1/dojox/layout/resources/GridContainer.css' rel='stylesheet' type='text/css' /> 
     <script src='//ajax.googleapis.com/ajax/libs/dojo/1.9.1/dojo/dojo.js'></script> 
     <style type='text/css'> 
     html,body,#border { margin:0; width:100%; height:100%; } 
     </style> 
    </head> 
    <body class='claro'> 
     <div id='border' data-dojo-type='dijit/layout/BorderContainer'> 
      <div id='grid'></div> 
     </div> 
     <script type='text/javascript'> 
     require(
      ['dojo/ready', 'dojo/parser', 'dojox/layout/GridContainer', 'dojox/widget/Portlet'], 
      function (ready, Parser, GridContainer, Portlet) { 
       ready(function() { 
        Parser.parse().then(function() { 
         // create grid and put into border container 
         var grid = new GridContainer({nbZones:3}, 'grid'); 

         // create cells and put into grid 
         for (var i = 0; i < 30; i++) { 
          grid.addChild(new Portlet({ 
           closable:false, 
           content:'(' + Math.floor(i/3) + ', ' + (i%3) + ')' 
          })); 
         } 
         grid.startup(); 
        }); 
       }); 
      } 
     ); 
     </script> 
    </body> 
</html>