angularjs - Is it possible to bind the sorting of a column to a different property than its display property with Angular UI Grid? -


i wondering if knew of way sort column in same order column using angular ui grid.

i'm guessing mean if (for example) have "first name" , "last name" columns display first name , last name respectively, want click sort on "last name" , sorts table in order of "first name"?

if so, can accomplish using cell template.

assume have following table:

enter image description here

and when sort "last name" column sort table in order of data in "first name" column.

assuming following data:

$scope.gridoptions.data = [{     "firstname": "david",     "lastname": "carney", }, {     "firstname": "bob",     "lastname": "wise", }, {     "firstname": "peter",     "lastname": "thompson", }]; 

define columndefs follows:

$scope.gridoptions.columndefs = [{     name: 'firstname',     field: 'firstname' }, {     name: 'lastname',     field: 'firstname',     celltemplate: '<div class="ui-grid-cell-contents">{{row.entity.lastname}}</div>' }]; 

the column definition second column names column "last name" , cell template ensures lastname attribute displayed in cell, column's field bound firstname means when column sorted sorted on firstname.

an example can found here. sort second column (last name) , rows sorted in order of first column (first name).


Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -