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俱乐部是真的吗,wpk俱乐部怎么作必弊(透视)确实真的是有方法(哔哩哔哩)1、辅助器...
脚本普及!aapoker怎么开... 脚本普及!aapoker怎么开辅助器,aapoker ai插件(透视)总是存在有软件(哔哩哔哩)1、...
透视推荐!德普之星有辅助软件吗... 透视推荐!德普之星有辅助软件吗,德扑之心免费透视(透视)都是是真的攻略(哔哩哔哩)1)辅助插件:进一...
透视分享!aapoker如何设... 透视分享!aapoker如何设置胜率,aapoker免费透视脚本(透视)原来存在有攻略(哔哩哔哩)进...
透视揭露!德州hhpoker脚... 透视揭露!德州hhpoker脚本,hhpoker怎么破解(透视)竟然是真的方法(哔哩哔哩)1)有没有...
透视教你!德州局怎么透视,hh... 透视教你!德州局怎么透视,hhpoker哪个俱乐部靠谱(透视)确实有软件(哔哩哔哩)小薇(辅助器软件...
脚本科普!hhpoker作必弊... 脚本科普!hhpoker作必弊实战视频,hh poker透视器下载(透视)真是是有挂(哔哩哔哩)1、...
脚本普及!aapoker怎么控... 脚本普及!aapoker怎么控制牌,aapoker俱乐部靠谱吗(透视)总是有软件(哔哩哔哩)1、脚本...
脚本解谜!aapoker插件下... 脚本解谜!aapoker插件下载,aapoker如何设置胜率(透视)原来真的是有教程(哔哩哔哩)1、...
脚本解密!德普之星透视辅助软件... 脚本解密!德普之星透视辅助软件下载,德普之星透视辅助软件下载(透视)真是存在有软件(哔哩哔哩)1、脚...