Pregunta

En el pasado, he usado una plantilla de manillar de vainilla para crear una tabla con enlaces a otras plantillas como también.

<tbody>
        {{#each}}
            <tr>
                <th>
                    {{#link-to 'entities.entity' actorId}}{{/link-to}}
                </th>
                {{#each alsoKnownAs}}
                <td>
                    {{this}}
                </td>
                {{/each}}
            </tr>
        {{/each}}
        </tbody>

utilizando el marco Ember-Table, he refactorado esa plantilla a

<div style="height: 800px;width: 100%;">
{{table-component
  hasFooter=false
  enableContentSelection=true
  columns=columns
  content=controller}}
</div>

Mi controlador ahora parece

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]

y mi plantilla personalizada entidades / profile_link

<th>{{#link-to 'entities.entity' actorId}}{{/link-to}}</th>

¿Cómo configuro mi controlador para que cuando hago clic en una celda en la columna 'nombre de entidad' enlaces a mi plantilla personalizada?

¿Fue útil?

Solución

en lugar de TableCellViewClass: 'profile_link'

Puede definir la plantilla en línea:

tableCellViewClass: Ember.Table.TableCell.extend
        template: Em.Handlebars.compile """
          {{#link-to 'entities.entity' view.cellContent}}
            {{view.cellContent}}
          {{/link-to}}
"""

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top