0
votes

Cannot set width for autogenerated Kendo UI Grid for angular. I want to set the width same as I am setting the field name and title and datatype.

I tried adding a property width to my ColumnSetting Array, then tried to just add a fixed width setting when generating the columns as shown in code below but it does not work

Expected result is that the Column Widths are set by the data provided in the ColumnSetting array. At present the width is not changing.

1
my code:kendo-grid-column *ngFor="let column of columns" field="{{column.field}}" title="{{column.title}}" format="{{column.format}}" filter="{{column.type}}" [width]="400" ></kendo-grid-column> and : - Vikram Jhurry
also tried:kendo-grid-column *ngFor="let column of columns" field="{{column.field}}" title="{{column.title}}" format="{{column.format}}" filter="{{column.type}}" [width]="{{column.width}}" ></kendo-grid-column> - Vikram Jhurry

1 Answers

0
votes

The solution is this:

    <kendo-grid
    [data]="gridView"
    [loading]="loading"
    [skip]="skip"
    [pageSize]="pageSize"
    [scrollable]="'virtual'"
    [rowHeight]="35"
    [height]="450"
    (pageChange)="pageChange($event)"
    [navigable]="true"
  >
  <kendo-grid-column  *ngFor="let column of columns" [width]="column.width"
  field="{{column.field}}"
  title="{{column.title}}"
  format="{{column.format}}"
  filter="{{column.type}}" ></kendo-grid-column> 
</kendo-grid>

    public columns: ColumnSetting[] = [
{
  field: 'Id',
  title: 'Id',
  type: 'text',
  width: "100px"
}, {
  field: 'firstName',

  title: 'FirstName',
  type: 'text',
  width: "20px"
}, {
  field: 'lastName',
  width: "40px",
  title: 'LastName',
  type: 'text'
}

];