简体   繁体   中英

ngx-datatable weird behavior (Black background to rows & pixelated fonts)

For the reference of this issue I am attaching images too.

I am using ngx-datatable to display data. When I try to continuously hover over rows that are visible there are three cases that happens.

  1. One row's background gets black;
  2. One row's text gets pixelated;
  3. One row's text isn't visible;

If anyone has encountered this issue then please help. Here's my code:

Here's the HTML

This is the attribute that I have removed: 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>

Here's the TS File

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);
  }

}

Case One:(Only this time both happened at the same time) 在此处输入图片说明

Case Two: 在此处输入图片说明

Case Three: Wasn't able to reproduce this issue again...

I was initially using Angular 5 and didn't find any solution with it. I recently upgraded the project to Angular 7.2.3 and upgraded the packages and this issue automatically got fixed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM