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



相关内容

热门资讯

2027版辅助!锋视棋牌辅助多... 2027版辅助!锋视棋牌辅助多功能AI插件,锋视棋牌一贯真的有辅助插件1、锋视棋牌脚本辅助下载、锋视...
2027版开挂!小猪堆堆碰开挂... 2027版开挂!小猪堆堆碰开挂多功能AI教程,小猪堆堆碰确实真的是有开挂教程1、首先打开小猪堆堆碰辅...
玩家实测辅助挂!欢乐茶馆ai辅... 玩家实测辅助挂!欢乐茶馆ai辅助挂多功能插件,从前真的是有辅助挂方法讲义是一款可以让一直输的玩家,快...
2027版辅助器!金虎爷辅助器... 2027版辅助器!金虎爷辅助器多功能AI软件,金虎爷好像真的是有辅助器软件1、打开软件启动之后找到中...
指导大家透视挂!熊猫互娱ai透... 一款 AI 游戏攻略黑科技工具上线,查攻略效率直接开挂。它整合版本更新、装备搭配、BOSS 打法、牌...
2027版开挂!易来麻将开挂多... 2027版开挂!易来麻将开挂多功能AI方法,易来麻将好像真的有开挂方法1、易来麻将免费辅助多个强度级...
今日焦点辅助!朝阳麻将ai辅助... 今日焦点辅助!朝阳麻将ai辅助多功能插件,往昔是有辅助软件模块是一款可以让一直输的玩家,快速成为一个...
重要通知辅助!杭州都莱麻将ai... 您好,重要通知辅助!杭州都莱麻将ai辅助多功能插件,其实真的是有辅助攻略绝活儿这款游戏可以开挂的,确...
2027版透视器!同城上饶透视... 2027版透视器!同城上饶透视器多功能AI攻略,同城上饶果然是真的有透视器攻略1、很好的工具软件,可...
2027版辅助器!聚乐麻将辅助... 2027版辅助器!聚乐麻将辅助器多功能AI技巧,聚乐麻将真是存在有辅助器技巧在进入聚乐麻将软件靠谱后...