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



相关内容

热门资讯

透视中牌率"德州透视... 透视中牌率"德州透视插件"详细辅助专业教程(原来有挂)1、不需要AI权限,帮助你快速的进行德州透视插...
透视透视"模拟器打开... 透视透视"模拟器打开hhpoker"详细辅助2025新版(果然是真的有挂)1、不需要AI权限,帮助你...
透视教程"wepok... 透视教程"wepoker可以开透视吗"详细辅助AI教程(一直是真的有挂);人气非常高,ai更新快且高...
透视辅助"菠萝德州透... 透视辅助"菠萝德州透视脚本"详细辅助德州论坛(从前真的有挂);大神普及一款德州ai内幕,确定了菠萝德...
透视辅助"aapok... 透视辅助"aapoker透视脚本入口"详细辅助2025新版总结(本来真的有挂);亲真的是有正版授权,...
透视总结"hhpok... 1、透视总结"hhpoker德州透视"详细辅助曝光教程(往昔有挂)。2、hhpoker德州透视透视辅...
透视规律"竞技联盟透... 1、透视规律"竞技联盟透视"详细辅助攻略教程(最初真的是有挂)(UU poker、竞技联盟透视、xp...
透视透视挂"如何下载... 透视透视挂"如何下载德普之星辅助软件"详细辅助必赢教程(一向有挂)科技教程也叫必备教程,这是一款功能...
透视脚本"聚星ai辅... 透视脚本"聚星ai辅助工具下载"详细辅助科技教程(真是真的有挂)1、许多玩家不知道聚星ai辅助工具下...
透视透视"hhpok... 透视透视"hhpoker德州透视"详细辅助总结教程(从来真的有挂)1、玩家可以在hhpoker德州透...