AngularSlickgrid提示框在单元格值变化时未更新
创始人
2024-10-29 16:00:51
0

问题的解决方法是使用Angular Slickgrid的onCellChange事件来强制更新提示框。以下是一个示例代码:

import { Component, OnInit } from '@angular/core';
import { AngularGridInstance, Column, FieldType, Formatters, GridOption } from 'angular-slickgrid';

@Component({
  templateUrl: './my-component.html'
})
export class MyComponent implements OnInit {
  columnDefinitions: Column[];
  gridOptions: GridOption;
  dataset: any[];

  angularGrid: AngularGridInstance;
  isGridInitialized = false;

  ngOnInit(): void {
    this.columnDefinitions = [
      { id: 'title', name: 'Title', field: 'title', width: 70 },
      { id: 'duration', name: 'Duration (days)', field: 'duration', width: 70, formatter: Formatters.decimal },
      { id: 'complete', name: '% Complete', field: 'percentComplete', minWidth: 90, formatter: Formatters.percentCompleteBar },
      { id: 'start', name: 'Start', field: 'start', minWidth: 60 },
      { id: 'finish', name: 'Finish', field: 'finish', minWidth: 60 },
      { id: 'effort-driven', name: 'Effort Driven', field: 'effortDriven', minWidth: 60 }
    ];

    this.gridOptions = {
      enableCellNavigation: true,
      enableColumnResize: true,
      enableAutoResize: true
    };

    this.dataset = this.getData(500);

    this.isGridInitialized = true;
  }

  angularGridReady(angularGrid: AngularGridInstance) {
    this.angularGrid = angularGrid;
  }

  onCellChanged(event: any, args: any) {
    // Force cell to redraw by triggering a cell change event
    // This will cause the Tooltip to read from the updated value
    this.angularGrid.grid.invalidate();
    const cell = this.angularGrid.grid.getActiveCell();
    this.angularGrid.grid.scrollCellIntoView(cell.row, cell.cell);
  }

  private getData(count: number) {
    const process = [];
    for (let i = 0; i < count; i++) {
      const rand = Math.floor(Math.random() * 100);
      process.push({
        id: i,
        title: 'Task ' + i,
        duration: rand,
        percentComplete: rand,
        start: new Date(2009, 0, 1),
        finish: new Date(2009, 0, 1),
        effortDriven: i % 5 === 0
      });
    }
    return process;
  }
}

在模板中,将onCellChanged函数作为onCellChange事件的处理程序绑定到单元格上:



相关内容

热门资讯

wepoke插件!wepoke... wepoke插件!wepoke辅助插件(透明挂)WepOke(一般真的有挂)1、点击下载安装,微扑克...
3分钟了解!南通长牌app有人... 3分钟了解!南通长牌app有人操作吗,友乐麻将赢牌,新版2025教程(有挂细节)1、实时南通长牌ap...
重大推荐!途游游戏辅助工具(透... 重大推荐!途游游戏辅助工具(透视)原来有挂(2020已更新)(哔哩哔哩)1、该软件可以轻松地帮助玩家...
微扑克有辅助挂!wpk微扑克真... 微扑克有辅助挂!wpk微扑克真的有辅助插件(透视辅助)总是是真的有挂1、玩家可以在微扑克软件透明挂俱...
AI教程!wepower线上游... AI教程!wepower线上游戏发牌机制规律(wepoke辅助德之星)wepOke(就是真的有挂);...
微扑克辅助挂!微扑克有计算器(... 微扑克辅助挂!微扑克有计算器(透视辅助)果然存在有挂是一款可以让一直输的玩家,快速成为一个“必胜”的...
重大通报!血战到底有外 挂么(... 重大通报!血战到底有外 挂么(辅助)好像真的是有挂(2021已更新)(哔哩哔哩)该软件可以轻松地帮助...
五分钟了解!poker wor... 五分钟了解!poker world有挂吗,掌中乐游戏中心辅助器,2025新版教程(有挂脚本);1、全...
AA德州教程!wepower有... AA德州教程!wepower有辅助软件(wepoke插件)wEPOKE(的确真的有挂);值得一提的是...
微扑克辅助软件!微扑克有辅助,... 微扑克辅助软件!微扑克有辅助,微扑克真是有挂,wpk教程(有挂解说)1、这是跨平台的微扑克黑科技,在...