0
그리드를 표시하려면 부모 div에 특정 높이가 필요하다는 것을 알고 있습니다. 이제 행 수에 따라 눈금이 줄어들거나 늘어나기를 바랍니다.내용에 따라 Dojo DataGrid의 높이를 어떻게 변경합니까?
그리드를 표시하려면 부모 div에 특정 높이가 필요하다는 것을 알고 있습니다. 이제 행 수에 따라 눈금이 줄어들거나 늘어나기를 바랍니다.내용에 따라 Dojo DataGrid의 높이를 어떻게 변경합니까?
다음은 그리드의 최대 높이를 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();
}
});