0

我想在我的页面中使用 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>

我想创建一些列,使它看起来像一个表。我怎样才能做到这一点??有人能帮我吗

4

1 回答 1

1

根据您的标题“Dojo BorderContainer 中创建列”(重点是我的),那么我认为边框容器内的dgridtable containergrid 容器会适合,具体取决于您尝试使用表格完成的操作。

如果该表用于数据,请考虑 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>
于 2013-10-25T11:38:58.023 回答