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事件的处理程序绑定到单元格上:



相关内容

热门资讯

第六分钟开挂!桃乐甘肃麻将下载... 第六分钟开挂!桃乐甘肃麻将下载辅助器,兴动互娱辅助工具名称(玩家必看科普开挂辅助平台) 了解更多开挂...
四分钟辅助!樱花之盛辅助器,闲... 四分钟辅助!樱花之盛辅助器,闲逸亲友圈辅助器(透视总结开挂辅助软件);详细闲逸亲友圈辅助器攻略(闲逸...
2分钟辅助!hhpoker为什... 2分钟辅助!hhpoker为什么一直输,创思维app有挂吗(技术分享开挂辅助插件);1.创思维app...
9分钟透视!欢聚水鱼辅助视频,... 9分钟透视!欢聚水鱼辅助视频,盛世辅助软件(热点讨论开挂辅助插件)1、下载安装好欢聚水鱼辅助视频,进...
7分钟辅助!有没有人会衢州都莱... 7分钟辅助!有没有人会衢州都莱的辅助,新道游游戏辅助器免费版(大家学习交流开挂辅助平台);致您一封信...
第七分钟辅助!山西扣点免费辅助... >>您好:山西扣点免费辅助下载确实是有挂的,很多玩家在这款山西扣点免费辅助下载游戏中打牌都会发现很多...
2分钟开挂!博雅棋牌辅助器,潮... 潮汕木虱有辅助挂吗是一款专注玩家量身打造的游戏记牌类型软件,在潮汕木虱有辅助挂吗这款游戏中我们可以记...
第7分钟辅助!新二号辅助下载,... 第7分钟辅助!新二号辅助下载,创思维激k必胜辅助(今日头条开挂辅助安装);1、不需要AI权限,帮助你...
五分钟辅助!微友辅助神器下载,... 五分钟辅助!微友辅助神器下载,小闲川南辅助工具(一分钟揭秘开挂辅助神器);AI辅助机器人普及解说快速...
五分钟辅助!微乐小程序辅助教程... 五分钟辅助!微乐小程序辅助教程,传送屋有没有挂(终于知道开挂辅助工具)>>您好:软件加薇136704...