pull/256/head
cagataycivici 2020-03-16 19:34:32 +03:00
parent 1c178dcc8b
commit b76a9c502f
1 changed files with 22 additions and 16 deletions

View File

@ -100,11 +100,10 @@ export default {
this.virtualScrollCallback(); this.virtualScrollCallback();
this.virtualScrollCallback = null; this.virtualScrollCallback = null;
} }
this.setScrollHeight();
}, },
watch: { watch: {
scrollHeight() {
this.setScrollHeight();
},
totalRecords(newValue) { totalRecords(newValue) {
if (this.virtualScroll) { if (this.virtualScroll) {
this.$refs.virtualScroller.style.height = newValue * this.virtualRowHeight + 'px'; this.$refs.virtualScroller.style.height = newValue * this.virtualRowHeight + 'px';
@ -162,21 +161,28 @@ export default {
}, },
setScrollHeight() { setScrollHeight() {
if (this.scrollHeight) { if (this.scrollHeight) {
if(this.scrollHeight.indexOf('%') !== -1) { let frozenView = this.$el.previousElementSibling;
let datatableContainer = this.findDataTableContainer(this.$el); if (frozenView) {
this.$refs.scrollBody.style.visibility = 'hidden'; let frozenScrollBody = DomHandler.findSingle(frozenView, '.p-datatable-scrollable-body');
this.$refs.scrollBody.style.height = '100px'; //temporary height to calculate static height this.$refs.scrollBody.style.maxHeight = frozenScrollBody.style.maxHeight;
let containerHeight = DomHandler.getOuterHeight(datatableContainer);
let relativeHeight = DomHandler.getOuterHeight(datatableContainer.parentElement) * parseInt(this.scrollHeight, 10) / 100;
let staticHeight = containerHeight - 100; //total height of headers, footers, paginators
let scrollBodyHeight = (relativeHeight - staticHeight);
this.$refs.scrollBody.style.height = 'auto';
this.$refs.scrollBody.style.maxHeight = scrollBodyHeight + 'px';
this.$refs.scrollBody.style.visibility = 'visible';
} }
else { else {
this.$refs.scrollBody.style.maxHeight = this.scrollHeight; if(this.scrollHeight.indexOf('%') !== -1) {
let datatableContainer = this.findDataTableContainer(this.$el);
this.$refs.scrollBody.style.visibility = 'hidden';
this.$refs.scrollBody.style.height = '100px'; //temporary height to calculate static height
let containerHeight = DomHandler.getOuterHeight(datatableContainer);
let relativeHeight = DomHandler.getOuterHeight(datatableContainer.parentElement) * parseInt(this.scrollHeight, 10) / 100;
let staticHeight = containerHeight - 100; //total height of headers, footers, paginators
let scrollBodyHeight = (relativeHeight - staticHeight);
this.$refs.scrollBody.style.height = 'auto';
this.$refs.scrollBody.style.maxHeight = scrollBodyHeight + 'px';
this.$refs.scrollBody.style.visibility = 'visible';
}
else {
this.$refs.scrollBody.style.maxHeight = this.scrollHeight;
}
} }
} }
}, },