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



相关内容

热门资讯

透视总结!hhpoker德州有... 透视总结!hhpoker德州有挂吗(AApoker ai插件)一贯真的有辅助脚本(哔哩哔哩)hhpo...
此事引发网友热议!微乐小程序黑... 此事引发网友热议!微乐小程序黑科技免费,微信小程序游戏破解微乐辅助(透视)都是是真的辅助教程(哔哩哔...
透视积累!哈糖大菠萝能开挂吗(... 透视积累!哈糖大菠萝能开挂吗(WePoKer官方)一直真的有辅助脚本(哔哩哔哩)哈糖大菠萝能开挂吗脚...
做出回应!微乐小程序免费黑科技... 做出回应!微乐小程序免费黑科技,微乐自建房免费黑科技下载(透视)其实是有辅助插件(哔哩哔哩)1、进入...
事发当天!微乐小程序免费黑科技... 事发当天!微乐小程序免费黑科技,微乐辅助靠谱麻(透视)总是存在有辅助器(哔哩哔哩)脚本下载中分为三种...
透视积累!wepokerplu... 透视积累!wepokerplus辅助(WePoKer国外版)果然是真的有辅助脚本(哔哩哔哩)透视积累...
透视了解!微乐小程序黑科技免费... 透视了解!微乐小程序黑科技免费,淘宝的微乐辅助是真的吗(透视)好像存在有辅助脚本(哔哩哔哩)1、上手...
透视办法!we-poker辅助... 透视办法!we-poker辅助器(HHpoker脚本)其实有辅助教程(哔哩哔哩)1、首先打开we-p...
透视美元局!微信微乐游戏辅助脚... 透视美元局!微信微乐游戏辅助脚本,微乐小程序辅助器代理(透视)竟然是真的辅助工具(哔哩哔哩);脚本下...
透视策略!pokemmo辅助器... 透视策略!pokemmo辅助器手机版下载(WPK控制牌)好像真的有辅助神器(哔哩哔哩)小薇(辅助器软...