Angular 如何将ngx完美滚动条应用于ag网格
我一直在兜圈子,想申请工作。我可以让两者分开工作,但我想用完美的滚动条完全替换datatable上的默认滚动条 我已按照以下要求设置了我的模块: 在我的模板中:Angular 如何将ngx完美滚动条应用于ag网格,angular,ag-grid,perfect-scrollbar,Angular,Ag Grid,Perfect Scrollbar,我一直在兜圈子,想申请工作。我可以让两者分开工作,但我想用完美的滚动条完全替换datatable上的默认滚动条 我已按照以下要求设置了我的模块: 在我的模板中: <perfect-scrollbar class="psc"> <ag-grid-angular #agGrid style="width:100%;height:100%" class="ag-dark" [gridOptions]="gridOptions"
<perfect-scrollbar class="psc">
<ag-grid-angular #agGrid style="width:100%;height:100%" class="ag-dark"
[gridOptions]="gridOptions"
[rowData]="rowData">
</ag-grid-angular>
</perfect-scrollbar>
但我也不能让它工作;我刚刚收到“无默认导出”错误
欢迎指点。感谢您尝试像这样导入完美的滚动条:
import * as perfectScrollbar from 'perfect-scrollbar';
private runPerfectScrollbar() {
const agBodyViewport = window.document.getElementsByClassName('ag-body-viewport')[0];
this.perfectScrollbar = new PerfectScrollbar(agBodyViewport);
this.perfectScrollbar.update();
然后可以使用perfectScrollbar.initialize()和perfectScrollbar.update() 尝试像这样导入完美的滚动条:
import * as perfectScrollbar from 'perfect-scrollbar';
private runPerfectScrollbar() {
const agBodyViewport = window.document.getElementsByClassName('ag-body-viewport')[0];
this.perfectScrollbar = new PerfectScrollbar(agBodyViewport);
this.perfectScrollbar.update();
然后可以使用perfectScrollbar.initialize()和perfectScrollbar.update() 我在ag网格中实现了它:
import * as perfectScrollbar from 'perfect-scrollbar';
private runPerfectScrollbar() {
const agBodyViewport = window.document.getElementsByClassName('ag-body-viewport')[0];
this.perfectScrollbar = new PerfectScrollbar(agBodyViewport);
this.perfectScrollbar.update();
}SuppressColumnVirtualization:window.navigator.userAgent.toLowerCase().indexOf('firefox')>-1上看到性能问题?真:假。
(当然,用某种方法写得更好;)
但令我惊讶的是,它为我解决了其他一些问题。例如,我在firefox上没有更多的延迟。在safari上,我在overscroll上没有橡皮筋效果我也不确定ag网格中的所有设置。我有我的观点。所以我只能显示有限的行。但是如果您有一些问题,我会尽力帮助您。我在ag grid angular中实现了它:
import * as perfectScrollbar from 'perfect-scrollbar';
private runPerfectScrollbar() {
const agBodyViewport = window.document.getElementsByClassName('ag-body-viewport')[0];
this.perfectScrollbar = new PerfectScrollbar(agBodyViewport);
this.perfectScrollbar.update();
}SuppressColumnVirtualization:window.navigator.userAgent.toLowerCase().indexOf('firefox')>-1上看到性能问题?真:假。
(当然,用某种方法写得更好;)
但令我惊讶的是,它为我解决了其他一些问题。例如,我在firefox上没有更多的延迟。在safari上,我在overscroll上没有橡皮筋效果我也不确定ag网格中的所有设置。我有我的观点。所以我只能显示有限的行。但是如果您有一些问题,我会尽力帮助您。在ag grid angular中添加完美滚动条的步骤(水平+垂直)。
从“完美滚动条”导入完美滚动条代码>
perfect scrollbar.css
.ag实体视口、.ag实体水平滚动视口{
位置:相对位置;
溢出:隐藏!重要;
}
onGridReady(参数:any,gridContainer){
让数组=[“.ag主体视口”、“.ag主体水平滚动视口”]
array.forEach(元素=>{
let container=gridContainer.querySelector(元素)
if(集装箱){
const ps=新的滚动条(容器);
ps.update();
}
});
}
将ag grid angular中的完美滚动条添加到angular 7应用程序的步骤(水平+垂直)。
从“完美滚动条”导入完美滚动条代码>
perfect scrollbar.css
.ag实体视口、.ag实体水平滚动视口{
位置:相对位置;
溢出:隐藏!重要;
}
onGridReady(参数:any,gridContainer){
让数组=[“.ag主体视口”、“.ag主体水平滚动视口”]
array.forEach(元素=>{
let container=gridContainer.querySelector(元素)
if(集装箱){
export class TableComponent {
public width: number = null; // This must be null otherwise it does not work properly after calling the sizeColumnsToFit function
@ViewChild(PerfectScrollbarDirective, { static: false })
public directiveRef?: PerfectScrollbarDirective;
public config: PerfectScrollbarConfigInterface = {};
public constructor(private store: Store<AppState>, private elementRef: ElementRef) {}
public onColumnResized(): void {
this.updateTableWidth();
}
private updateTableWidth(): void {
const agBodyViewport: HTMLElement = this.elementRef.nativeElement.querySelector(".ag-body-viewport");
if (agBodyViewport) {
if (agBodyViewport) {
this.width = agBodyViewport.scrollWidth > agBodyViewport.offsetWidth ? agBodyViewport.scrollWidth : null;
this.directiveRef.update();
}
}
}
}