【问题标题】:How do you make the height of a Dojo DataGrid change based on it contents如何根据内容更改 Dojo DataGrid 的高度
【发布时间】:2013-08-19 01:58:00
【问题描述】:

我知道为了让网格显示父 div 需要一个特定的高度。现在我希望网格根据行数缩小或增加高度。

【问题讨论】:

    标签: datagrid height dojo


    【解决方案1】:

    以下内容将使网格的最大高度为 300 像素,但如果仅显示几行,则会缩小它。

    父div

    var divGrid = domConstruct.toDom("<div id='divGrid' style='height:300px;'></div>");
    domConstruct.place(divGrid, dojo.byId('Contents'));
    

    创建网格

    var grid = new DataGrid({
       id: 'grid',
       store: store,
       structure: layout,
       style: "height:300px",
       loadingMessage: "Loading...",
       noDataMessage: "No data...",
       selectionMode: 'single',
       rowSelector: '20px'
    });
    grid.placeAt(divGrid);
    grid.startup();
    

    现在加载网格后

    dojo.connect(grid, '_onFetchComplete', function() {
       var list = query('#grid .dojoxGridContent');
       var height = list[0].offsetHeight + 25;  // additional 25 to account for headers
       if (height < 300) {
          dojo.byId("divGrid").style.height = height + 'px';
          dojo.byId("grid").style.height = height + 'px';
          grid.resize();
          grid.update();
       }
    });
    

    【讨论】:

      猜你喜欢
      • 2013-03-06
      • 1970-01-01
      • 2012-09-28
      • 2012-01-06
      • 1970-01-01
      • 1970-01-01
      • 2022-06-23
      • 2019-12-03
      • 1970-01-01
      相关资源
      最近更新 更多