【问题标题】:How to set column width of autogenerated columns in Kendo UI Grid for angular如何在 Kendo UI Grid 中为角度设置自动生成列的列宽
【发布时间】:2019-01-28 07:55:18
【问题描述】:

无法为自动生成的 Kendo UI Grid 设置宽度。我想将宽度设置为与设置字段名称、标题和数据类型相同。

我尝试向我的 ColumnSetting 数组添加一个属性宽度,然后尝试在生成列时添加一个固定宽度设置,如下面的代码所示,但它不起作用

预期结果是列宽由 ColumnSetting 数组中提供的数据设置。目前宽度没有变化。

【问题讨论】:

  • 我的代码: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 *ngFor="let column of columns" field="{{column.field}}" title="{{column.title}}" format=" {{column.format}}" filter="{{column.type}}" [width]="{{column.width}}" >

标签: angular kendo-grid autogeneratecolumn


【解决方案1】:

解决办法是这样的:

    <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'
}

];

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-03-11
    • 2015-04-16
    • 2012-11-03
    • 1970-01-01
    • 2022-09-28
    • 1970-01-01
    • 2011-11-08
    • 1970-01-01
    相关资源
    最近更新 更多