angular - 隱藏 ag-grid 狀態欄
這個問題是關於隨 Enterprise 版本附帶的 ag-grid 狀態欄。我目前使用的是搭配 Angular 7 的 ag-grid-community 19.1。
我正在尋找隱藏狀態列的最佳方法?即使我完全不包含 statusBar 網格選項,我的網格底部仍然會看到空白區域(雖然是空的),本應顯示狀態列的位置。檢查生成的 HTML 時發現存在以下內容:
<!--AG-STATUS-BAR-->
<div class="ag-status-bar" ref="statusBar">
<div ref="eStatusBarLeft" class="ag-status-bar-left"></div>
<div ref="eStatusBarCenter" class="ag-status-bar-center"></div>
<div ref="eStatusBarRight" class="ag-status-bar-right"></div>
</div>
現在如果我在 Chrome 控制台中完全移除那一部分,它就會如預期消失。但是我嘗試過透過 CSS 來做到這點,但似乎不起作用:
.ag-status-bar {
height: 0px;
}
老實說,我更希望能通過在 statusBar 網格選項中的設置以程式化的方式來實現,但我在 ag-grid 文檔中沒有看到類似的內容。
任何幫助都感激不盡;謝謝。
答案#1
在網格選項中不設置 statusBar 應該足以讓狀態欄不出現。
所以,我覺得除了透過 CSS 做以下操作,沒有其他選擇:
.ag-status-bar {
display: none;
}
答案#2
當我完全不包含 statusBar 網格選項時,我仍然在我的網格底部看到空白空間(雖然是空的),那裡本應該是狀態欄的位置。
同意。當我不在 gridOptions 中包含它時,它根本不應該出現。不過無論如何,我還是會提供我找到的資訊,希望對某些人有幫助。
順帶一提,標記仍然會存在於 DOM 中。所以,如果你根本不想看到它,@Diogo Rocha 提供的解決方案將是正確的方法。
您可以透過存取狀態列面板實例來以程式方式更改其可見性
toggleStatusBarComp() {
let statusBarComponent = this.gridApi.getStatusPanel("statusBarCompKey");
let componentInstance = statusBarComponent;
if (statusBarComponent.getFrameworkComponentInstance) {
componentInstance = statusBarComponent.getFrameworkComponentInstance();
}
componentInstance.setVisible(!componentInstance.isVisible());
}
看看文件中的這個範例:取得狀態欄面板實例
