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



相关内容

热门资讯

解密透视!wepoker分析,... 解密透视!wepoker分析,sohoo竞技联盟辅助器,练习教程(有挂技巧)-哔哩哔哩1、sohoo...
必备透视!sohoopoker... 必备透视!sohoopoker辅助!总是一直都是有辅助方法(有挂方法)-哔哩哔哩1、很好的工具软件,...
总结透视!哈糖大菠萝有没有挂,... 总结透视!哈糖大菠萝有没有挂,pokemmo手机脚本辅助器,诀窍教程(证实有挂)-哔哩哔哩pokem...
专业透视!pokemmo辅助官... 专业透视!pokemmo辅助官网!其实是真的有辅助软件(有挂秘笈)-哔哩哔哩1、专业透视!pokem...
了解透视!佛手在线是不是有挂,... 了解透视!佛手在线是不是有挂,德普之星app安卓版破解版,办法教程(有挂功能)-哔哩哔哩1、下载好德...
揭露透视!哈糖大菠萝破解器!一... 揭露透视!哈糖大菠萝破解器!一贯一直总是有辅助方法(有挂神器)-哔哩哔哩1、哈糖大菠萝破解器脚本辅助...
教你透视!wepoker私局代... 教你透视!wepoker私局代打,wepoker私人局俱乐部怎么进,要领教程(有挂头条)-哔哩哔哩运...
详情透视!agpoker辅助!... 详情透视!agpoker辅助!切实是有辅助教程(有挂教程)-哔哩哔哩1、上手简单,内置详细流程视频教...
了解透视!大菠萝789辅助器下... 了解透视!大菠萝789辅助器下载,wpk透视辅助下载,妙招教程(有挂详细)-哔哩哔哩所有人都在同一条...
分享透视!pokemmo辅助脚... 分享透视!pokemmo辅助脚本!其实真的有辅助方法(揭秘有挂)-哔哩哔哩1)pokemmo辅助脚本...