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



相关内容

热门资讯

总算明白透视器!海螺互娱透视器... 总算明白透视器!海螺互娱透视器多功能AI方法,海螺互娱其实真的有透视器方法运海螺互娱辅助工具,进入游...
终于懂了透视器!圣光大厅透视器... 终于懂了透视器!圣光大厅透视器多功能AI攻略,圣光大厅切实真的有透视器攻略1、很好的工具软件,可以解...
发现玩家辅助器!老夫子大厅辅助... 发现玩家辅助器!老夫子大厅辅助器多功能AI攻略,老夫子大厅原来存在有辅助器攻略暗藏猫腻,小编详细说明...
一分钟带你了解辅助器!新乐酷副... 一分钟带你了解辅助器!新乐酷副厅辅助器多功能AIapp,新乐酷副厅原来是真的有辅助器app1.新乐酷...
重大推荐作弊器!牛将军互娱作弊... 重大推荐作弊器!牛将军互娱作弊器多功能AI攻略,牛将军互娱确实是真的有作弊器攻略小薇(辅助器软件下载...
推荐十款辅助!悠悠互娱辅助多功... 推荐十款辅助!悠悠互娱辅助多功能AIapp,悠悠互娱切实是真的有辅助app1、悠悠互娱模拟器是什么优...
实测交流外挂!新烛龙外挂多功能... 实测交流外挂!新烛龙外挂多功能AI脚本,新烛龙总是是真的有外挂脚本1、新烛龙有没有辅助教程、新烛龙有...
盘点一款外挂!八戒大厅外挂多功... 盘点一款外挂!八戒大厅外挂多功能AI插件,八戒大厅好像有外挂插件1、八戒大厅破解器简单,八戒大厅机器...
推荐一款作弊器!众享互娱作弊器... 推荐一款作弊器!众享互娱作弊器多功能AI方法,众享互娱真是真的有作弊器方法;1、推荐一款作弊器!众享...
普及知识开挂!918娱乐开挂多... 普及知识开挂!918娱乐开挂多功能AI方法,918娱乐切实真的有开挂方法1、完成918娱乐辅助器v3...