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下载窍门!aapoker... WPK下载窍门!aapoker辅助挂,德州微扑克原来是真的有开挂插件aapoker辅助挂能透视中分为...
WPK透视大纲!wepoker... WPK透视大纲!wepokerplus外挂,德州微扑克本来有辅助app1、下载好wepokerplu...
WPK安装策略!wepoker... WPK安装策略!wepoker透视脚本免费,德州微扑克都是是真的有开挂方法1、许多玩家不知道wepo...
WPK私人局要领!wepoke... WPK私人局要领!wepoker私人辅助器,德州微扑克竟然有透视工具1、许多玩家不知道wepoker...
WPK德州局诀窍!WePOke... WPK德州局诀窍!WePOker有没有透视方法,德州微扑克其实真的有透视app在进入WePOker有...
WPK有透视资料!we-pok... WPK有透视资料!we-poker辅助器,德州微扑克原来存在有开挂攻略1、操作简单,无需we-pok...
WPK透视操作!wepoker... WPK透视操作!wepoker透视脚本视频,德州微扑克一贯存在有辅助器工具1、该软件可以轻松地帮助玩...
WPK脚本窍门!wepoker... WPK脚本窍门!wepoker黑侠破解,德州微扑克好像是真的有辅助app1、操作简单,无需wepok...
WPK作弊手筋!wepoker... 您好,wepoker怎么设置房间这款游戏可以开挂的,确实是有挂的,需要了解加去威信【13670430...
WPK脚本大纲!wepoker... WPK脚本大纲!wepoker辅助器激活码,德州微扑克总是有透视神器1、完成wepoker辅助器激活...