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



相关内容

热门资讯

第7分钟带你透视!欢乐茶馆修改... 第7分钟带你透视!欢乐茶馆修改器辅助,皇豪互众辅助软件是干嘛的,力荐教程(有挂教程)-哔哩哔哩>>您...
第二分钟带你辅助!天天爱柳州有... 第二分钟带你辅助!天天爱柳州有没有辅助器,心悦游戏辅助,AI教程(今日头条)-哔哩哔哩>>您好:软件...
第二分钟带你开挂!518互游私... 【亲,新广西老友辅助 这款游戏可以开挂的,确实是有挂的,很多玩家在这款新广西老友辅助中打牌都会发现很...
一分钟带你讲解!白金岛透视插件... 较多好评“微乐万能挂官网”开挂(透视)辅助教程 了解更多开挂安装加(136704302)微信号是一款...
八分钟带你透视!找浙江宝宝游戏... 【亲,找浙江宝宝游戏辅助插件 这款游戏可以开挂的,确实是有挂的,很多玩家在这款找浙江宝宝游戏辅助插件...
5分钟带你了解!福建天天开心万... 5分钟带你了解!福建天天开心万能辅助,约局吧辅助,可靠教程(有挂详情)-哔哩哔哩福建天天开心万能辅助...
第三分钟带你讲究!星悦云南丽江... 第三分钟带你讲究!星悦云南丽江卡二辅助,樱花之盛辅助器,普及教程(有挂总结)-哔哩哔哩;无需打开直接...
第5分钟带你透视!来趣广西辅助... 第5分钟带你透视!来趣广西辅助,新青鸟必胜,新版2026教程(今日头条)-哔哩哔哩 >>您好:软件加...
第二分钟带你科普!微乐小程序多... 第二分钟带你科普!微乐小程序多乐辅助器,哥哥打大a游戏攻略,揭秘教程(存在有挂)-哔哩哔哩 >>您好...
第八分钟带你科普!赣牌圈控制牌... 第八分钟带你科普!赣牌圈控制牌型,掌中乐游戏辅助工具,科技教程(有挂技巧)-哔哩哔哩 了解更多开挂安...