ngx-datatable怪异行为(行背景为黑色背景和像素化字体)

时间:2019-01-29 07:36:23

标签: javascript angular typescript ngx-datatable

对于这个问题,我也附上图片。

我正在使用ngx-datatable显示数据。当我尝试将鼠标悬停在可见行上时,会发生三种情况。

  1. 一行的背景变黑;
  2. 一行的文本被像素化;
  3. 看不到一行文本;

如果有人遇到此问题,请提供帮助。这是我的代码:

  

这是HTML

这是我已删除的属性: columnMode =“ force”

<ngx-datatable
  class="material"
  [rows]="rows"
  [rowHeight]="80"
  [scrollbarV]="true"
  [scrollbarH]="true">
    <ngx-datatable-column [width]="30" name="Sr#" prop="sr"></ngx-datatable-column>
    <ngx-datatable-column [width]="350" name="KPIs" prop="kpis"></ngx-datatable-column>
    <ngx-datatable-column [width]="60" name="Weight" prop="weight"></ngx-datatable-column>
    <ngx-datatable-column [width]="200" name="KRA" prop="kra"></ngx-datatable-column>
    <ngx-datatable-column [width]="60" name="Jul" prop="months.jul"></ngx-datatable-column>
    <ngx-datatable-column [width]="60" name="Aug" prop="months.aug"></ngx-datatable-column>
    <ngx-datatable-column [width]="60" name="Sep" prop="months.sep"></ngx-datatable-column>
    <ngx-datatable-column [width]="60" name="Oct" prop="months.oct"></ngx-datatable-column>
    <ngx-datatable-column [width]="60" name="Nov" prop="months.nov"></ngx-datatable-column>
    <ngx-datatable-column [width]="60" name="Dec" prop="months.dec"></ngx-datatable-column>
    <ngx-datatable-column [width]="80" name="Avg Target Ach" prop="avgTargetAchOne"></ngx-datatable-column>
    <ngx-datatable-column [width]="80" name="Avg Target Kpi Wei" prop="avgTargetKpiWeiOne"></ngx-datatable-column>
    <ngx-datatable-column [width]="60" name="Jan" prop="months.jan"></ngx-datatable-column>
    <ngx-datatable-column [width]="60" name="Feb" prop="months.feb"></ngx-datatable-column>
    <ngx-datatable-column [width]="60" name="Mar" prop="months.mar"></ngx-datatable-column>
    <ngx-datatable-column [width]="60" name="Apr" prop="months.apr"></ngx-datatable-column>
    <ngx-datatable-column [width]="60" name="May" prop="months.may"></ngx-datatable-column>
    <ngx-datatable-column [width]="60" name="Jun" prop="months.jun"></ngx-datatable-column>
    <ngx-datatable-column [width]="80" name="Avg Target Ach" prop="avgTargetAchTwo"></ngx-datatable-column>
    <ngx-datatable-column [width]="80" name="Avg Target Kpi Wei" prop="avgTargetKpiWeiTwo"></ngx-datatable-column>
    <ngx-datatable-column [width]="150" name="yardsticks"></ngx-datatable-column>
    <ngx-datatable-column [width]="250" name="remarks"></ngx-datatable-column>
</ngx-datatable>
  

这是TS文件

export class CompObjectivesComponent implements OnInit {

  rows = [];

  constructor() {
    this.fetch((data) => {
      // this is an anonymous function that assign data to rows after fetching
      this.rows = data;
      console.log(this.rows)
    });
  }

  ngOnInit() {}

  // this method gets the data from a json file I have in assets
  fetch(cb) {
    const req = new XMLHttpRequest();
    req.open('GET', `assets/100k.json`);

    req.onload = () => {
      cb(JSON.parse(req.response));
    };

    req.send();
  }

  addRow() {
    // this is something I have to work on later
    const obj = {
      "id": 0.0,
      "name": "Immad Hamid",
      "gender": "male",
      "age": 25,
      "address": {
          "state": "Sindh",
          "city": "Karachi"
      }
    }

    this.rows.push(obj);
    console.log(this.rows);
  }

}
  

案例一:(仅这次两者同时发生)   enter image description here

     

第二种情况:   enter image description here

     

案例三:   无法再次重现此问题...

1 个答案:

答案 0 :(得分:0)

我最初使用的是Angular 5,但没有找到任何解决方案。我最近将项目升级到Angular 7.2.3并升级了软件包,此问题自动得到解决。