2013-08-16 3 views

답변

1

다음은 그리드의 최대 높이를 300px로 지정하지만 표시되는 행이 2 개 밖에없는 경우 축소됩니다.

부모 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(); 
    } 
}); 
관련 문제