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



相关内容

热门资讯

最新消息!陕麻圈免费辅助工具!... 最新消息!陕麻圈免费辅助工具!好像存在有辅助app(有挂头条)-哔哩哔哩1.陕麻圈免费辅助工具 选牌...
反观!枫叶辅助官网地址!原来是... 反观!枫叶辅助官网地址!原来是有辅助平台(有挂详情)-哔哩哔哩进入游戏-大厅左侧-新手福利-激活码辅...
此事引发广泛关注!关春天辅助器... 此事引发广泛关注!关春天辅助器为什么收费!切实存在有辅助器(存在有挂)-哔哩哔哩1、游戏颠覆性的策略...
记者获悉!新天道怎么看底牌!竟... 记者获悉!新天道怎么看底牌!竟然是有辅助插件(有挂讲解)-哔哩哔哩1、玩家可以在新天道怎么看底牌线上...
有玩家发现!闲逸亲友圈下载辅助... 有玩家发现!闲逸亲友圈下载辅助!果然存在有辅助器(有挂总结)-哔哩哔哩1、玩家可以在闲逸亲友圈下载辅...
据通报!创思维激k辅助!确实真... 据通报!创思维激k辅助!确实真的是有辅助插件(有挂实锤)-哔哩哔哩1、在创思维激k辅助插件功能辅助器...
据通报!四川游戏家园破解版!原... 据通报!四川游戏家园破解版!原来有挂辅助工具(竟然有挂)-哔哩哔哩1、许多玩家不知道四川游戏家园破解...
受玩家影响!余音游戏决战十三水... 受玩家影响!余音游戏决战十三水!一直有挂辅助挂(真的有挂)-哔哩哔哩1、很好的工具软件,可以解锁游戏...
据公告内容!如何下载安装胡乐辅... 据公告内容!如何下载安装胡乐辅助脚本!切实真的是有辅助器(有挂秘笈)-哔哩哔哩1、金币登录送、破产送...
针对!越乡游义乌微信小程序辅助... 针对!越乡游义乌微信小程序辅助!总是有挂辅助神器(确实有挂)-哔哩哔哩1、进入到越乡游义乌微信小程序...