javascript - Ascending/Descending filter Strings on ng-grid -


trying out ascending , descending type of sorting in angular js strings

here plunker select box has 2 options ascending , descending

when ascending chosen grid should output values importance in order l-m-h stands low-medium-high , descending h-m-l

i have asked these questions sorry can't concepts right sorting , filtering in angular js

update

i had implemented part of have sorted contents in same order

stack question here have used drop down selection. , same drop down has 2 more options of ascending , descending trying find out answers.

i don't know of non-hackish way of using external select such show in plunker.

as sorting itself, can create , use custom sorting function:

var prioritysort = function(a, b){     var priority = { l: 1, m: 2, h: 3 };     if(priority[a] > priority[b]) return 1;     if(priority[a] < priority[b]) return -1;     return 0; };  $scope.gridoptions = {     data: 'mydata',     enablesorting: true,     showfilter: true,     columndefs: [{ field: 'name', displayname: 'name'},     { field: 'age', displayname: 'age' },     { field: 'importance', displayname: 'importance', sortfn: prioritysort}] }; 

demo


Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -