Clarity: [DOCS] Document Datagrid column's [(clrSortOrder)] two-way binding

Created on 30 Jun 2017  路  6Comments  路  Source: vmware/clarity

EDIT by @youdz: This is a case of missing documentation, so I renamed the issue. The feature already exists.

Select one ... (check one with "x")

[ ] bug
[x] feature request
[ ] enhancement

Expected behavior

I wish to sort a datagrid when initialized (ex: sort employees by salary ascendingly).
I could be like :

<clr-dg-column [clrDgField]="'salary'" [clrSort]="{asc: true}">Salary</clr-dg-column>

Actual behavior

There is no Angular options to set this (or is there another way?)

Environment details

  • Angular version: 4.2.X

  • Clarity version: 0.9.11

bug

Most helpful comment

Updated plnkr per youdz's comment.
https://plnkr.co/edit/KnbmPwuhzz9WdpZtcqtd?p=preview

All 6 comments

@samdidos

From this example,
https://plnkr.co/edit/E102mEUHDzQvyccsEYKw?p=preview

please see this:
<clr-dg-column [clrDgSortBy]="'salary'" [clrDgSortOrder]="1">Salary</clr-dg-column>

SortOrder:
https://github.com/vmware/clarity/blob/master/src/clarity-angular/data/datagrid/interfaces/sort-order.ts

Property shortcut on clrDgSortBy is new commit. If not work with your Clarity version, use 'clrDgField' instead of 'clrDgSortBy' both create same default Datagrid comparator if string input provided to clrDgSortBy.

Also, you can define your own comparator and use it with clrDgSortBy.

As @chunghha said, it's already possible using the [clrDgSortOrder]. For cleanliness though, I don't recommend you use -1/0/1 directly, but rather the enum we provide:

import {SortOrder} from 'clarity-angular';

this.preSorted = SortOrder.Asc;

And then, as posted above,

<clr-dg-column [clrDgField]="'salary'" [clrDgSortOrder]="preSorted">Salary</clr-dg-column>

If you don't mind, I'm going to rename this issue as a documentation issue, because that's what we really are missing.

Updated plnkr per youdz's comment.
https://plnkr.co/edit/KnbmPwuhzz9WdpZtcqtd?p=preview

Added an example to the docs for this here: https://github.com/vmware/clarity/pull/2039

Hi there 馃憢, this is an automated message. To help Clarity keep track of discussions, we automatically lock closed issues after 14 days. Please look for another open issue or open a new issue with updated details and reference this one as necessary.

Was this page helpful?
0 / 5 - 0 ratings