public get gridOptions(): GridOptions { const that = this; return { headerHeight: 30,// 表頭高度 rowHeight: 30,// 行高 columnDefs: [//列定義 { headerName: '規則唯一號', field: 'RuleCode', width: 90, }, { headerName: '醫療單元號', field: 'UnitId', width: 90, }, { headerName: '系統分類', field: 'SysType', width: 80, }, { headerName: '子系統分類', field: 'SubsysType', width: 90, }, { headerName: '序列號中文名稱', field: 'KeyName', width: 120, }, { headerName: '前綴', field: 'KeyPrechar', width: 80, }, { headerName: '格式化編號類型', field: 'KeyFmtcodeType', width: 120, cellRenderer: (params) => { for (const item of this.fmtcodeTypeArr) { if (item.value === params.data.KeyFmtcodeType) { return '<span>' + item.label + '</span>'; } } }, }, { headerName: '順序號長度', field: 'KeySeqnumLen', width: 90, }, { headerName: '順序號的開始數字', field: 'KeySeqnumBgn', width: 130, }, { headerName: '是否加醫療單元號', field: 'CanAddUnitid', width: 130, valueGetter(params) { return params.data.CanAddUnitid === 0 ? false : true; }, valueFormatter(params) { return params.value ? '√' : ''; }, }, { headerName: '數據庫連接名', field: 'CnName', width: 110, }, { headerName: '注冊方式', field: 'RegWay', width: 80, valueFormatter(params) { return params.data.RegWay === 1 ? '預注冊' : '運行時注冊'; }, }, { headerName: '停用標志', field: 'StopMark', width: 80, valueFormatter(params) { return params.data.StopMark === 0 ? '' : '√'; }, }, ], showToolPanel: false, // 顯示工具欄 enableSorting: true,//允許排序 enableColResize: true,//允許調整列寬 suppressLoadingOverlay: true,// 去掉表格加載數據提示 suppressNoRowsOverlay: true,// 去掉表格無數據提示 suppressDragLeaveHidesColumns: true,//防止拖動的時候隱藏表格列 suppressContextMenu: true,// 阻止表格的右鍵菜單 defaultColDef: { suppressMenu: true,//隱藏表頭菜單 }, onRowSelected: this.RowSelected,//行選中回調 rowSelection: 'single',//只允許單行選中 isExternalFilterPresent: () => this.filterStart,//是否允許外部篩選 doesExternalFilterPass: this.IfNodeVisible,//外部篩選條件 onFilterChanged() {//篩選條件改變回調 this.api.deselectAll(); that.selectedRow = false; }, navigateToNextCell: (params) => {// 鍵盤操作選中行 let previousCell = params.previousCellDef; const suggestedNextCell = params.nextCellDef; const KEY_UP = 38; const KEY_DOWN = 40; const KEY_LEFT = 37; const KEY_RIGHT = 39; switch (params.key) { case KEY_DOWN: previousCell = params.previousCellDef; this.gridOptions.api.forEachNode((node) => { if (previousCell.rowIndex + 1 === node.rowIndex) { node.setSelected(true); } }); return suggestedNextCell; case KEY_UP: previousCell = params.previousCellDef; this.gridOptions.api.forEachNode((node) => { if (previousCell.rowIndex - 1 === node.rowIndex) { node.setSelected(true); } }); return suggestedNextCell; case KEY_LEFT: case KEY_RIGHT: return suggestedNextCell; default: break; } }, }; }