Solved

Sorting grid by multiple columns in angularjs

Posted on 2016-11-07
3
29 Views
Last Modified: 2016-11-09
Hi
I need to do Sorting grid with multiple columns in angularjs
Thanks
0
Comment
Question by:Member_2_7967608
  • 2
3 Comments
 
LVL 82

Expert Comment

by:leakim971
ID: 41878085
<gridrow ng-repeat="row in rows | orderBy:['column1','column3','column2','column0']">
    <gridcell>{{row.column0}}</gridcell>
    <gridcell>{{row.column1}}</gridcell>
    <gridcell>{{row.column2}}</gridcell>
    <gridcell>{{row.column3}}</gridcell>
    <gridcell>{{row.column4}}</gridcell>
    <gridcell>{{row.column5}}</gridcell>
</gridrow>

Open in new window

0
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 41878268
Test page : https://jsfiddle.net/ymdbp8zt/1/

<div ng-app="myApp">
  <table ng-controller="myCtrl">
    <tr ng-repeat="row in rows | orderBy:['column1','column3','column2','column0']">
        <td>{{row.column0}}</td>
        <td>{{row.column1}}</td>
        <td>{{row.column2}}</td>
        <td>{{row.column3}}</td>
        <td>{{row.column4}}</td>
        <td>{{row.column5}}</td>
    </tr>
  </table>
</div>

Open in new window


var myApp = angular.module("myApp", []);
myApp.controller("myCtrl", ["$scope", function($scope) {
	$scope.rows = [
		{column0:"A",column1:"4",column2:"123",column3:"AZD"},  
		{column0:"A",column1:"3",column2:"124",column3:"AZC"},  
		{column0:"A",column1:"3",column2:"123",column3:"AZC"},  
		{column0:"B",column1:"0",column2:"123",column3:"AZA"},  
		{column0:"A",column1:"0",column2:"123",column3:"AZA"}  
  ];
}]);

Open in new window

0
 

Author Comment

by:Member_2_7967608
ID: 41880378
Thanks
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now