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



相关内容

热门资讯

实测揭晓!线上德州的辅助器是什... 实测揭晓!线上德州的辅助器是什么,wepoker辅助器软件下载,高科技教程(有挂神器)1、不需要AI...
教学盘点!hhpoker有没有... 教学盘点!hhpoker有没有作弊挂,agpoker辅助,规律教程(有挂软件)关于hhpoker有没...
玩家亲测!佛手在线是不是有挂,... 玩家亲测!佛手在线是不是有挂,aapoker插件下载,必备教程(有挂神器);小薇(透视辅助)致您一封...
终于清楚!hhpoker到底可... 1、终于清楚!hhpoker到底可以作弊吗,来玩app破解,详细教程(有挂技巧)2、进入游戏-大厅左...
分享个大家!aapoker a... 分享个大家!aapoker ai插件,红龙poker辅助工具,专业教程(有挂教程),支持语音通讯、好...
终于知道!aapoker透视脚... 终于知道!aapoker透视脚本下载,uupoker透视,新版2025教程(有挂辅助);大神普及一款...
每日必看!xpoker辅助怎么... 每日必看!xpoker辅助怎么用,wepoker钻石怎么看底牌,安装教程(有挂技巧)1、很好的工具软...
分享一款!hhpoker免费透... 这是一款非常优秀的hhpoker免费透视脚本 ia辅助检测软件,能够让你了解到hhpoker免费透视...
关于!wpk透视辅助方法,po... 关于!wpk透视辅助方法,pokemmo脚本手机版,攻略教程(有挂软件)1、很好的工具软件,可以解锁...
指导大家!pokemmo脚本辅... 指导大家!pokemmo脚本辅助器,德州局透视,力荐教程(有挂辅助)关于pokemmo脚本辅助器机制...