Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

kendo ui - How to implement dropdown list in a grid for kendoUI for angular. Can't find any documentation

Something like this. But this example is for kendoUI for jquery. I need documentation for kendoUI for angular.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I do it in my application. Here is a simple version of it:

HTML Template

<kendo-grid [data]="someData" [height]="750">
  <kendo-grid-column field="LaborType" title="Task" width="120">
    <ng-template kendoGridCellTemplate let-dataItem>
      {{ GetLaborTypeDesc(dataItem.LaborType)?.LaborTypeDesc }}
    </ng-template>
    <ng-template kendoGridEditTemplate>
      <kendo-dropdownlist [defaultItem]="{LaborTypeID: null, LaborTypeDesc: 'Select a task...'}" [data]="LaborTypes"
        textField="LaborTypeDesc" valueField="LaborTypeID" [valuePrimitive]="true">
      </kendo-dropdownlist>
    </ng-template>
  </kendo-grid-column>
</kendo-grid>

Typescript

  LaborTypes: Array<{ LaborTypeDesc: string, LaborTypeID: number }> = [];

  public GetLaborTypeDesc(id: number): any {
    return this.LaborTypes.find(x => x.LaborTypeID === id);
  }

I have Add, Edit, and Delete commands in my grid that involves a form not seen here. I populate the LaborTypes object array in my ngOnInit function as well, so the user has options to choose in the dropdown.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...