AnsweredAssumed Answered

Hierarchy of layouts BorderContainer and ContentPane

Question asked by leonid.ko on Dec 8, 2016
Latest reply on Dec 12, 2016 by leonid.ko

Hello! I am trying to add toolbars into map and table in FeatureTable-example from
https://developers.arcgis.com/javascript/3/jssamples/featuretable.html

<!DOCTYPE html>
<html>

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <title>Using FeatureTable</title>
  <link rel="stylesheet" href="https://js.arcgis.com/3.18/dijit/themes/claro/claro.css">
  <link rel="stylesheet" href="https://js.arcgis.com/3.18/esri/css/esri.css">
  <script src="https://js.arcgis.com/3.18/"></script>

  <style>
    html, body, #map{
      width:100%;
      height:100%;
      margin:0;
      padding:0;
    }
  </style>


  <script>
    require([
      "esri/layers/FeatureLayer",
      "esri/dijit/FeatureTable",
      "esri/geometry/webMercatorUtils",
      "esri/map",
      "dojo/dom-construct",
      "dojo/dom",
      "dojo/parser",
      "dojo/ready",
      "dojo/on",
      "dojo/_base/lang",
      "dijit/registry",
      "dijit/form/Button",
      "dijit/layout/ContentPane",
      "dijit/layout/BorderContainer",
      "dijit/form/TextBox"
    ], function (
      FeatureLayer, FeatureTable, webMercatorUtils, Map,
      domConstruct, dom, parser, ready, on,lang,
      registry, Button, ContentPane, BorderContainer, TextBox
    ) {
      parser.parse();

      ready(function(){

        var myFeatureLayer;
        var map = new Map("map",{
          basemap: "dark-gray"
        });

        map.on("load", loadTable);

        function loadTable(){
          // Create the feature layer
          myFeatureLayer = new FeatureLayer("https://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/Warren_College_Trees/FeatureServer/0", {
            mode: FeatureLayer.MODE_ONDEMAND,
            visible: true,
             outFields: [
              "Collected", "Status", "Spp_Code", "Height", "Cmn_Name", "Sci_Name", "Street", "Native"
            ],
            id: "fLayer"
          });

          //set map extent
          on(myFeatureLayer, "load", function(evt){
            var extent = myFeatureLayer.fullExtent;
            if (webMercatorUtils.canProject(extent, map)) {
              map.setExtent( webMercatorUtils.project(extent, map) );
            }
          });

          map.addLayer(myFeatureLayer);

          myFeatureTable = new FeatureTable({
            "featureLayer" : myFeatureLayer,
            "outFields": [
              "Collected", "Spp_Code", "Height", "Cmn_Name", "Sci_Name", "Native"
            ],
            fieldInfos: [
              {
                name: 'Spp_Code',
                alias: 'Species Code',
              },
              {
                name: 'Cmn_Name',
                alias: 'Common Name',
              },
              {
                name: 'Sci_Name',
                alias: 'Scientific Name',
              }
            ],
            "map" : map
          }, 'myTableNode');
          myFeatureTable.startup();
        };
     on(dom.byId("homebutton"), "click", function(){
          Fun1('1');
        });
     on(dom.byId("butbutton"), "click", function(){
          Fun1('2');
        });     
      });
      function Fun1(Msg){window.alert(Msg);};
    });
  </script>

</head>

<body class="claro esri">
  <div data-dojo-type="dijit/layout/BorderContainer" data-dojo-props="design:'headline'" style="width:100%; height:100%;">
    <div data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'center', splitter:true" style="height:50%">
      <div id="navToolbar" data-dojo-type="dijit/Toolbar" data-dojo-props="region:'top'" >
         <div data-dojo-type="dijit/form/Button" id="homebutton" >Home</div>
      </div>
      <div id="map"></div>
    </div>
    <div id="bot" data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'bottom', splitter:true" style="height:50%">
      <div id="navToolbarBot" data-dojo-type="dijit/Toolbar" data-dojo-props="region:'top'" >
         <div data-dojo-type="dijit/form/Button" id="butbutton" >Some</div>
      </div>
      <div id="myTableNode"></div>
    </div>
  </div>
</body>
</html>


I have added toolbars with buttons but now I see excess scroll-bars. It's not good.
Then I changed ContentPane to BorderContainer and set property "region":

<body class="claro esri">
  <div data-dojo-type="dijit/layout/BorderContainer" data-dojo-props="design:'headline'" style="width:100%; height:100%;">
    <div data-dojo-type="dijit/layout/BorderContainer" data-dojo-props="region:'center'" >
      <div id="navToolbar" data-dojo-type="dijit/Toolbar" data-dojo-props="region:'top'" >
         <div data-dojo-type="dijit/form/Button" id="homebutton" >Home</div>
      </div>
      <div id="map" data-dojo-props="region:'center'"></div>
    </div>
    <div id="bot" data-dojo-type="dijit/layout/BorderContainer" data-dojo-props="region:'bottom', splitter:true, style:'height:200px'">
      <div id="navToolbarBot" data-dojo-type="dijit/Toolbar" data-dojo-props="region:'top'" >
         <div data-dojo-type="dijit/form/Button" id="butbutton" >Some</div>
      </div>
      <div id="myTableNode" data-dojo-props="region:'center'"></div>
    </div>
  </div>
</body>


Now it looks better - without scroll-bars, but when I try to move splitter, bottom div run to top of screen.

Probably I don't understand something impotant.

Outcomes