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透视脚本,新海贝辅助器(透视)开挂辅助工具详细教程 >>您好:软件加薇...
教程书开挂"天天福建... 教程书开挂"天天福建十三张辅助器"开挂(修改器)辅助平台(有挂助手)1、下载安装好天天福建十三张辅助...
原先有辅助"逗娱科技... 原先有辅助"逗娱科技碰胡辅助"开挂(透视)辅助下载(专业教程有挂猫腻)>>您好:软件加1367043...
透视科技!微乐小程序晃晃脚本,... 微乐小程序晃晃脚本是一款专注玩家量身打造的游戏记牌类型软件,在微乐小程序晃晃脚本这款游戏中我们可以记...
积累辅助"蘑菇云辅助... 蘑菇云辅助怎么使用开挂教程视频分享装挂详细步骤在当今的网络游戏中,蘑菇云辅助怎么使用作为一种经典的娱...
原本有辅助"微乐自建... 原本有辅助"微乐自建房脚本免费下载"开挂(透视)辅助软件(安装教程有挂透视) 了解更多开挂安装加(1...
透视游戏!新久久辅助器,财神1... 透视游戏!新久久辅助器,财神13张辅助工具(透视)开挂辅助安装系统教程;无需打开直接搜索加(薇:13...
模块开挂"至友互娱情... 模块开挂"至友互娱情怀辅助"开挂(修改器)辅助插件(有挂工具)至友互娱情怀辅助ai黑科技系统规律教程...
原本有开挂"余干中至... 原本有开挂"余干中至五十k有挂装不"开挂(透视)辅助脚本(黑科技教程有挂解密)您好:余干中至五十k有...
透视了解!好友赣南新版本挂,新... 透视了解!好友赣南新版本挂,新海贝之城辅助(透视)开挂辅助神器2026新版这是一款可以让一直输的玩家...