我目前正在使用js-grid
从数据库查询返回的数据作为 Web 应用程序的一部分。所有功能似乎都按我的意愿运行;但是,当返回的数据导致整个网格的高度大于父元素的高度时,它会“溢出”。
例如,它应该如下所示:
我已将height
jsGrid 调用中的值设置为容器元素的值,并尝试使用 css 和 jQuery设置 aheight
和css 值。max-height
我还添加了 and 的溢出scroll
,auto
但没有效果。
function surfaceDataGrid(message, recipient) {
var fieldData = JSON.parse(message.Data);
activeRequests.splice(0, activeRequests.length);
var columns = getColumns(recipient);
var Columns = columns.list.length;
var recipientElement = '#' + recipient;
var gridHeight = $(recipientElement).height();
var gridWidth = $(recipientElement).width();
$(recipientElement).html('<div id="jsgrid"></div>');
if (fieldData.length !== 0) {
loggingAction('log', 'NOTIFICATION : Query returned ' + fieldData.length + ' rows of data. ');
$(recipientElement).children('#jsgrid').jsGrid({
data: fieldData,
editing: false,
fields: eval(columns),
height: gridHeight,
inserting: false,
pageindex: 1,
pagesize: 1,
paging: false,
selecting: "true",
sorting: true,
width: gridWidth,
});
var Rows = ($('.jsgrid-table tbody tr').length) - 3;
$('.jsgrid-table').removeAttr('style');
var gridheight2 = (gridHeight - 28) + "px";
var headerwidth = (gridWidth / Columns) + 'px';
$('.jsgrid-header-cell').width(headerwidth).width('28px');
$('.jsgrid-grid-body').css('margin-top', '28px');
$('.jsgrid .jsgrid-grid-body').css('height',gridheight2);
$('.jsgrid-table').width(gridWidth + 'px');
$('.jsgrid-grid-body .jsgrid-table').width(gridWidth + 'px').height(gridheight2 + 'px');
$('.jsgrid-row').attr("tabIndex", "1");
$('.jsgrid-alt-row').attr("tabIndex", "1");
}
else {
$(recipientElement).children().remove();
$(recipientElement).append('<div id="jsgrid"><h2 class="errorMessage" style="padding:1em;text-align:center;">No data returned.<br> Please resubmit!</h2></div>');
$(recipientElement).fadeIn(fadeINtiming);
loggingAction('log', 'NOTIFICATION : Query returned no data.');
}
$('tr').click(function () {
var instantVariable0 = $('.jsgrid-header-row').parent().children()[0];
var selectedType0 = $(instantVariable0).text();
var instantVariable1 = $(this).parent().children()[0];
gridValueSelected = $(instantVariable1).text();
loggingAction('log', 'NOTIFICATION : A cell has been clicked');
loggingAction('info', 'INFORMATION : Agent has selected ' + selectedType0.split(' ')[1] + ' value of "' + gridValueSelected + '".');
$(this).addClass('selectedRow').siblings().removeClass('selectedRow');
});
}