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



相关内容

热门资讯

wepower辅助器!wepo... wepower辅助器!wepoke德扑之星,德州扑克辅助器,黑科技教程(本然真的是有挂),支持语音通...
黑科技教程!(德州aapoke... 黑科技教程!(德州aapoker)透明挂辅助app,(aapokeR)真是真的是有挂,AI教程(有挂...
aapoker辅助工具存在!微... 这是一款非常优秀的wepoke怎么使用模拟器 ia辅助检测软件,能够让你了解到wepoke怎么使用模...
黑科技好友房!(aapoKer... 黑科技好友房!(aapoKer)透明挂辅助神器,(德州aapoker)原来真的是有挂,辅助教程(有挂...
德州辅助软件开发定制!fish... 此外,数据分析德州(德州辅助软件开发定制)辅助神器app还具备辅助透视行为开挂功能,通过对客户德州辅...
辅助黑科技!(AaPOKER)... 辅助黑科技!(AaPOKER)透明挂辅助器,(AApOKER)从来是真的有挂,微扑克教程(有挂软件)...
wpk德州职业代打!德扑之星怎... wpk德州职业代打!德扑之星怎么埋牌,微扑克真的有挂存在吗,解密教程(起初真的有挂)1、点击下载安装...
黑科技有挂!(aapokEr)... 黑科技有挂!(aapokEr)透明挂辅助脚本,(aapoKER)都是有挂,新版2025教程(有挂透明...
微扑克wpk透视辅助在哪下!a... 微扑克wpk透视辅助在哪下!aapoker软件app,gg扑克发牌机制测试,安装教程(从来真的有挂)...
黑科技教学!(aapoKer)... 1、黑科技教学!(aapoKer)透明挂辅助挂,(aa poker)确实是有挂,普及教程(有挂神器)...