0

I have a list of items , those items have a sortOrder number and a name I want to show it sorted by sortOrder but this is not working

<iron-data-table id="entriesList"
    as="item"
    details-enabled
    items="{{entries}}">

    <data-table-column name="Media" width="360px" flex="2" sort-by="item.sortOrder"> [[item.name]]
    </data-table-column>
    <data-table-column name="Skip" flex="0">
        <paper-checkbox checked="{{item.skip}}"></paper-checkbox>
    </data-table-column>
</iron-data-table>

.

88mary256
  • 1,354
  • 1
  • 8
  • 6
  • i have never used this element, but according to documentation, there is element `called data-table-column-sort` . https://saulis.github.io/iron-data-table/#data-table-column-sort . Could it be the reason? – Kuba Šimonovský Apr 27 '17 at 08:10

1 Answers1

0

Firstly, it should be:

<data-table-column name="Media" width="360px" flex="2" sort-by="sortOrder"> [[item.name]]
    </data-table-column>

Secondly, it won't autosort items for you, you need to sort entries by yourself, something like:

someFuncThatGeneratesEntries: function(entries) {
  return entries.sort((a, b) => Math.sign(a.sortOrder - b.sortOrder));
} 
Kyle
  • 184
  • 2
  • 13