KWe*_*iss 5 javascript focus ag-grid
我在网站上使用 AG Grid。当用户单击某个单元格时,该单元格将获得焦点并显示蓝色轮廓。
当用户单击网站上的某些其他元素时,我需要删除此焦点,但我不知道该怎么做。有没有可以设置的方法或属性?
将以下代码片段添加到您的 css 中
.ag-cell-focus, .ag-cell {
border: none !important;
}
Run Code Online (Sandbox Code Playgroud)
示例 - https://next.plnkr.co/edit/xO5N5u84U8n4HgK5
角度2+DEMO
ngAfterViewInit(){
let body = document.body;
body.addEventListener("mouseup", (e) => {
let container = this.agGrid._nativeElement;
if (!container.contains(e.target))
{
this.gridApi.clearFocusedCell();
}
})
}
Run Code Online (Sandbox Code Playgroud)
JavaScriptDEMO
var body = document.body;
body.addEventListener("mouseup", (e) => {
let gridDiv = document.querySelector('#myGrid')
if (!gridDiv.contains(e.target))
{
gridOptions.api.clearFocusedCell();
}
})
Run Code Online (Sandbox Code Playgroud)