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



相关内容

热门资讯

透视存在!sohoo辅助(透视... 透视存在!sohoo辅助(透视)一直真的有挂(详细辅助详细教程)1、在ai机器人技巧中,中转单元十分...
推荐攻略!hhpoker透视脚... 推荐攻略!hhpoker透视脚本下载,佛手大菠萝有挂吗,规律教程(有挂方法);最新版2024是一款经...
透视中牌率!werplan怎么... 透视中牌率!werplan怎么透视(透视)一直真的有挂(详细辅助攻略方法);1、实时开挂更新:用户可...
实测分享!约局吧德州真的有透视... 《实测分享!约局吧德州真的有透视挂吗,aapoker怎么选牌,插件教程(有挂软件)》 约局吧德州真的...
透视辅助!红龙poker辅助平... 透视辅助!红龙poker辅助平台(透视)好像真的有挂(详细辅助透牌教程);1、让任何用户在无需红龙p...
盘点几款!wepoker看底牌... 盘点几款!wepoker看底牌,wepoker模拟器哪个好用,技巧教程(有挂透明);实战中需综合运用...
透视挂透视!德普之星透视辅助软... 透视挂透视!德普之星透视辅助软件激活码(透视)都是是有挂(详细辅助揭秘教程);1、德普之星透视辅助软...
来一盘!hardrock透视工... 来一盘!hardrock透视工具,竞技联盟辅助,技巧教程(有挂技巧)1、玩家可以在hardrock透...
透视模拟器!wepoker亲友... 透视模拟器!wepoker亲友圈有用吗(透视)确实真的是有挂(详细辅助黑科技教程)一、软件透明挂的定...
分享实测!hardrock作弊... 分享实测!hardrock作弊,wpk透视辅助方法,可靠技巧(有挂透明)关于wpk透视辅助方法机制的...