Ember 테이블 테이블에 사용자 정의 셀 템플릿을 추가하는 방법
-
21-12-2019 - |
문제
과거에는 바닐라 핸들 바를 사용하여 다른 템플릿에 대한 링크가있는 테이블을 만들었습니다.
<tbody>
{{#each}}
<tr>
<th>
{{#link-to 'entities.entity' actorId}}{{/link-to}}
</th>
{{#each alsoKnownAs}}
<td>
{{this}}
</td>
{{/each}}
</tr>
{{/each}}
</tbody>
.
Ember-Table
프레임 워크를 사용하여 해당 템플릿을
<div style="height: 800px;width: 100%;">
{{table-component
hasFooter=false
enableContentSelection=true
columns=columns
content=controller}}
</div>
.
내 컨트롤러 이제
처럼 보입니다.entitiesController = Ember.ArrayController.extend
sortAscending: true
sortProperties: ['displayName']
profile_link: 'entities/profile_link'
columns: Ember.computed ->
AKA = Ember.Table.ColumnDefinition.create
columnWidth: 750
headerCellName: 'Also Known As'
textAlign: 'text-align-left'
getCellContent: (row) -> row['alsoKnownAs'].join(', ')
displayName = Ember.Table.ColumnDefinition.create
columnWidth: 200
headerCellName: 'Entity Name'
textAlign: 'text-align-left'
TableCellViewClass: 'profile_link'
getCellContent: (row) -> row['displayName']
[displayName, AKA]
.
및 내 사용자 정의 템플릿 엔티티 / profile_link
<th>{{#link-to 'entities.entity' actorId}}{{/link-to}}</th>
.
"Entity Name '열에서 셀을 클릭하면 내 사용자 정의 템플리트에 링크를 링크 할 수 있습니다.
해결책
TableCellViewClass: 'profile_link'
대신
템플릿 인라인을 정의 할 수 있습니다.
tableCellViewClass: Ember.Table.TableCell.extend
template: Em.Handlebars.compile """
{{#link-to 'entities.entity' view.cellContent}}
{{view.cellContent}}
{{/link-to}}
"""
. 제휴하지 않습니다 StackOverflow