2017-07-15 93 views
0

我一直在試圖將ngx-perfect-scrollbar應用於ag-grid。我可以單獨工作,但我想用完美的滾動條來完全替換我的數據表中的默認滾動條。如何將ngx-perfect滾動條應用於ag網格

我已經建立了我的模塊按their instructions

import { PerfectScrollbarModule } from 'ngx-perfect-scrollbar'; 
import { PerfectScrollbarConfigInterface } from 'ngx-perfect-scrollbar'; 

const PERFECT_SCROLLBAR_CONFIG: PerfectScrollbarConfigInterface = { 
    suppressScrollX: true 
}; 

@NgModule({ 
    declarations: [ 

    ], 
    imports: [ 
    PerfectScrollbarModule.forRoot(PERFECT_SCROLLBAR_CONFIG) 
    ] 
}) 

,並在我的模板:

<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> 

這隻會導致新的自定義滾動條出現的外部因素,包括數據網格與標準工具欄。我需要將這兩個指令都應用於​​我猜想的相同元素,但我失去了如何執行此操作。

我還試圖this approach,採用標準(非角度的)完美-滾動條包,並試圖當組件被加載到其綁定到正確.ag-body-viewport元件:

import perfectScrollbar from 'perfectScrollbar'; 

this.viewport = this.$element.find('.ag-body-viewport')[0]; 
perfectScrollbar.initialize(this.viewport); 

但我不能不要讓它工作;我剛剛得到「無默認導出」錯誤...

任何指針讚賞。由於

回答

0

嘗試導入完美的滾動條是這樣的:

import * as perfectScrollbar from 'perfect-scrollbar'; 

那麼你就可以perfectScrollbar.initialize()和perfectScrollbar.update()去;