Sushil Jadhav
Sushil Jadhav

Reputation: 2295

Angular-Slickgrid showing blank records

I am trying to show grid option in my application using angular slickgrid. I have referred wiki page to show grid but no data displaying in grid & even there is no error in browser console.

I have updated my app.module, Angular.json according to post but no use & grid displaying 0 records. I tried to create this problem using stackblitz but its not allowing me to install angular-slickgrid package so unable to post live sample.

My code

import { Component, OnInit } from '@angular/core';
import { Column, FieldType, Formatter, Formatters, GridOption }  from 'angular-slickgrid';

export class ReportComponent implements OnInit {
  columnDefinitions: Column[];
  gridOptions: GridOption;
  dataset: any[];

  ngOnInit(): void  
  {        
    this.gridOptions = {
      autoResize: {
        containerId: 'demo-container',
        sidePadding: 15
      },
      enableAutoResize: false,
      enableExcelCopyBuffer: true,

    };

    this.columnDefinitions = [
      { id: 'title', name: 'Title', field: 'title', sortable: true, type: FieldType.string, width: 70 }              
    ];

    this.dataset = [];
    for (let i = 0; i < 1000; i++) {    
      this.dataset[i] = {
        id: i, 
        title: 'Task ' + i
      };

    }

  }

}

My html

 <angular-slickgrid gridId="grid2" style="width:95%;"
                [columnDefinitions]="columnDefinitions"
                [gridOptions]="gridOptions"
                [dataset]="dataset">
            </angular-slickgrid>

Version I am using: jquery: ^3.3.1 angular-slickgrid: ^2.1.5 @angular/core: ^7.2.0

Upvotes: 2

Views: 1346

Answers (1)

Just code
Just code

Reputation: 13791

it's because you are using

enableAutoResize: false,

change it to

enableAutoResize : true

and it should work, when you work with false you need to give a height (using css) manually to the grid as per your needs. but when you allow true it will automatically set the size and resize on the browser resize.

demo

Upvotes: 2

Related Questions