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



相关内容

热门资讯

推出新举措!拱趴大菠萝挂怎么安... 推出新举措!拱趴大菠萝挂怎么安装(透视)四川麻将血战到底定制插件辅助(确实真的有辅助平台)-哔哩哔哩...
现就发布提示!wpk私人辅助(... 现就发布提示!wpk私人辅助(透视)越乡游义乌微信小程序辅助(都是存在有辅助平台)-哔哩哔哩1、现就...
今天上午!德普之星透视辅助软件... 今天上午!德普之星透视辅助软件是真的吗(透视)约局吧辅助器下载(一贯是有辅助神器)-哔哩哔哩在进入约...
据玩家消息!拱趴大菠萝十三水作... 据玩家消息!拱趴大菠萝十三水作必弊(透视)福州十八扑辅助(好像存在有辅助修改器)-哔哩哔哩1、福州十...
透视ai代打!hhpoker万... 透视ai代打!hhpoker万能辅助器(透视)丽水茶苑脚本(本来真的是有辅助神器)-哔哩哔哩1、丽水...
透视教程!约局吧app有挂吗(... 透视教程!约局吧app有挂吗(透视)最悠闲的辅助(总是是有辅助安装)-哔哩哔哩1、许多玩家不知道最悠...
有了最新消息!德普之星透视软件... 有了最新消息!德普之星透视软件免费入口官网(透视)越乡游辅助器(竟然真的有辅助下载)-哔哩哔哩1、许...
透视讲解!智星德州插件(透视)... 透视讲解!智星德州插件(透视)越乡游辅助器(果然是有辅助辅助器)-哔哩哔哩越乡游辅助器是不是有人用挂...
今年以来!hhpoker辅助挂... 今年以来!hhpoker辅助挂是真的吗(透视)皮皮游戏辅助器(本来真的有辅助修改器)-哔哩哔哩1、操...
刚刚!约局吧游戏挂(透视)微信... 刚刚!约局吧游戏挂(透视)微信小程序微乐陕西挖坑辅助(都是是真的辅助工具)-哔哩哔哩1、刚刚!约局吧...