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



相关内容

热门资讯

辅助透视!hhpoker透视工... 辅助透视!hhpoker透视工具(透视)荣耀拼三张辅助(其实真的有辅助平台)-哔哩哔哩在进入荣耀拼三...
现就发布提示!约局吧德州真的存... 现就发布提示!约局吧德州真的存在透视吗(透视)萍乡滚筒四幅攻略(好像存在有辅助平台)-哔哩哔哩1)萍...
透视科技!wepoker有插件... 透视科技!wepoker有插件吗(透视)四川途游辅助软件(切实存在有辅助修改器)-哔哩哔哩1、四川途...
透视计算!wepoker到底有... 透视计算!wepoker到底有没有透视(透视)东阳四副牌辅助(总是是真的辅助插件)-哔哩哔哩东阳四副...
透视总结!wpk显示有作必弊(... 透视总结!wpk显示有作必弊(透视)贵州闲来辅助工具(好像有辅助下载)-哔哩哔哩贵州闲来辅助工具透视...
透视科技!hhpoker德州作... 透视科技!hhpoker德州作必弊(透视)新老夫子挂(原来真的是有辅助修改器)-哔哩哔哩1、新老夫子...
据悉!wepoker辅助器下载... 据悉!wepoker辅助器下载(透视)兴动互娱辅助贴吧开挂(切实是有辅助插件)-哔哩哔哩1、兴动互娱...
此事引发广泛关注!wepoke... 此事引发广泛关注!wepokerplus透视脚本免费(透视)约战沙城辅助脚本(确实真的有辅助下载)-...
此事备受玩家关注!来玩app破... 此事备受玩家关注!来玩app破解版(透视)新玉海楼游戏茶苑(本来存在有辅助app)-哔哩哔哩该软件可...
截至发稿!wepoker买钻石... 截至发稿!wepoker买钻石有用吗(透视)阿拉游戏中心辅助(好像真的是有辅助插件)-哔哩哔哩阿拉游...