Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Toggle sort direction default via directive in <th> #33

Closed
tw-zz-rk opened this issue Jun 26, 2015 · 3 comments
Closed

Toggle sort direction default via directive in <th> #33

tw-zz-rk opened this issue Jun 26, 2015 · 3 comments

Comments

@tw-zz-rk
Copy link
Contributor

Feature request - would be nice to specify the default sort direction for a column via a directive in the <th>, as an example (note the order-direction attr):

<md-data-table-container>
      <table md-data-table md-row-select="tableConfig.selected">
          <thead md-trim-column-names md-order="tableConfig.order">
              <tr>
                  <th order-by="name">Report Name</th>
                  <th numeric order-by="views.value" order-direction="descending">Visits</th>
                  <th numeric order-by="users.value" order-direction="ascending">Unique Users</th>
              </tr>
          </thead>
          <tbody md-auto-select>
              <tr ng-repeat="report in reports_data | orderBy: tableConfig.order">
                  <td>{{report.name}}</td>
                  <td>{{report.views.value}}</td>
                  <td>{{report.users.value}}</td>
              </tr>
          </tbody>
      </table>
  </md-data-table-container>
@daniel-nagy
Copy link
Owner

I can see why this would be desirable. Are you thinking the attribute should restrict the direction to only sort descending or ascending, or just the default direction? order-direction makes it seem like it can only sort in that direction.

@tw-zz-rk
Copy link
Contributor Author

Thanks for the prompt response. Yeah, in my experience the user usually wants to see text columns alphabetically (so default ascending works well) and numeric columns from highest to lowest (or biggest to smallest). And to clarify, it would be the default sort direction, but the user could still toggle between either state. So order-direction is not a great name - perhaps order-default-direction or the like?

@daniel-nagy
Copy link
Owner

Okay, order-default-direction is a little verbose. We can probably think of something sorter that makes sense. I've been thinking of shortening some of the other attributes as well. For example, md-data-table-* would become md-table-*; md-data-table-pagination could just be md-pagination. I guess that is a personal preference but I think most people would prefer shorter attribute names. I'd end up breaking everyone's tables tough 😛

daniel-nagy pushed a commit that referenced this issue Jun 27, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants