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



相关内容

热门资讯

透视肯定“xpoker辅助助手... 透视肯定“xpoker辅助助手”透视辅助挂(总是真的有挂)1、每一步都需要思考,不同水平的挑战会更加...
透视真的!德普之星透视辅助插件... 透视真的!德普之星透视辅助插件,德普之星辅助器怎么用,透明挂教程(有挂辅助)1、用户打开应用后不用登...
透视安装“德州之星扫描器”透视... 透视安装“德州之星扫描器”透视辅助器(一贯有挂);1、德州之星扫描器ai辅助优化,德州之星扫描器发牌...
透视规律!德扑圈有透视吗,德普... 透视规律!德扑圈有透视吗,德普之星私人局透视,切实教程(有挂细节)1、德普之星私人局透视透视辅助简单...
透视实锤!pokemmo脚本最... 透视实锤!pokemmo脚本最新版,智星菠萝可以辅助吗,解密教程(有挂插件);智星菠萝可以辅助吗辅助...
透视了解!德普之星透视辅助软件... 透视了解!德普之星透视辅助软件,(德扑之心)原来真的有挂,AI教程(有挂细节)一、德普之星透视辅助软...
透视教程“聚星ai辅助工具激活... 透视教程“聚星ai辅助工具激活码”透视辅助挂(其实真的是有挂);1、打开软件启动之后找到中间准星的标...
透视好友!德普之星辅助工具如何... 透视好友!德普之星辅助工具如何设置,德普软件,2025新版(有挂工具)1、游戏颠覆性的策略玩法,独创...
透视好友“sohoo竞技联盟辅... 透视好友“sohoo竞技联盟辅助器”透视辅助工具(切实有挂);sohoo竞技联盟辅助器辅助器中分为三...
透视能赢!德普之星透视辅助,德... 透视能赢!德普之星透视辅助,德扑之心免费透视,2025新版总结(有挂辅助)1、超多福利:超高返利,海...