简体   繁体   中英

ember-table: Why is headerCellViewClass not respected?

UPDATE

You finally decide it's time to post on SO, you do so, and then you find a stupid error. Taken care of. Remove -> from Ember.Table.HeaderCell.extend -> .


I am attempting to customize my header cells for sorting purposes using the example in #183 . Unfortunately, The template I'm passing to headerCellViewClass is not being rendered.

I added in a random class and "asdf" just to prove to myself that my booleans weren't the issue. I can access out headerCellName, sorted, and supportSort through the console, and they all have their expected values.

Columns created in a loop in my controller

Ember.Table.ColumnDefinition.create App.SortableColumnMixin, {
      columnWidth: 100
      textAlign: 'text-align-left'
      tableCellViewClass: 'App.ReportValueCell'
      headerCellName: columnName
      contentPath: columnName
      isSortable: yes
}

You'll notice here that I set a custom tableCellViewClass. That one functions perfectly.

SortableColumnMixin

App.SortableColumnMixin = Ember.Object.create(
  supportSort: true
  sorted: false
  headerCellViewClass: 'App.SortableHeaderCell'
)

App.SortableHeaderCell

App.SortableHeaderCell = Ember.Table.HeaderCell.extend ->
    templateName: 'table/sortable-header-cell'

table/sortable-header-cell.hbs

<div class="ember-table-content-container" {{action sortByColumn view.content}}>

  <span class="ember-table-content" class="21340987235">
    asdf
    {{view.content.headerCellName}}

    {{#if view.content.supportSort}}
      <div style="float:right;">
        {{#if view.content.sorted}}
          {{#if sortAscending}}
            <div style="cursor:s-resize;" title="Ascending">
              &#8593; 
            </div>
          {{else}}
            <div style="cursor:n-resize;" title="Descending">
              &#8595;
            </div>
          {{/if}}
        {{else}}
          &#8645;
        {{/if}}
      </div>
    {{/if}}
  </span>
</div>

Inspector

Inspector

Does anyone know better than I why this might be?

UPDATE

You finally decide it's time to post on SO, you do so, and then you find a stupid error. Taken care of. Remove -> from Ember.Table.HeaderCell.extend ->.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM