Sort column as a integer
Thanks for contacting Syncfusion support.
While perform sorting operation, we are using typeOf property to check type of sorting data and based on that type, we are sorting the data. So you need to convert the data to integer before perform the sort operation.
Please find the code example and sample for workaround solution.
|
<script type="text/javascript"> angular.module('listCtrl', ['ejangular']) .controller('PhoneListCtrl', function ($scope, $compile, $filter, $rootScope) { $scope.data = [ { accessGroupMarking: "Country1", targetDescription: "Iphone 6", targetName: "2064-prod_SYSA", targetNumber: "1", targetType: "z/OS" }, { accessGroupMarking: "Country2", targetDescription: "Lenovo SS", targetName: "ADV-160", targetNumber: "111", targetType: "Oracle" }, { accessGroupMarking: "Country3", targetDescription: "Andy's Lenovo T60", targetName: "ACM-T60", targetNumber: "12", targetType: "Windows" }, { accessGroupMarking: "Country4", targetDescription: "Lenovo T60", targetName: "ACM-", targetNumber: "101", targetType: "Mac" }, { accessGroupMarking: "Country5", targetDescription: " Apple T80", targetName: "ACM-T65", targetNumber: "222", targetType: "Linux" } ]; $scope.columns = [ { field: "targetType", headerText: "targetType", width: 100 }, { field: "targetNumber", headerText: "targetNumber", width: 100 }, { field: "targetName", headerText: "targetName", width: 100 }, { field: "targetDescription", headerText: "description", width: 100 } ]; }); ej.pvt.fnAscending = function (x, y) { if (y === null || y === undefined) return -1;
if (parseFloat(x) != NaN) return parseFloat(x) - parseFloat(y);
if (typeof x === "string") return x.localeCompare(y);
if (x === null || x === undefined) return 1;
return x - y; } ej.pvt.fnDescending = function (x, y) { if (y === null || y === undefined) return 1;
if (parseFloat(x) != NaN) return parseFloat(y) - parseFloat(x);
if (typeof x === "string") return x.localeCompare(y) * -1;
if (x === null || x === undefined) return -1;
return y - x; } |
Sample Link: http://jsplayground.syncfusion.com/25gfyioj
Regards,
Sellappandi R
- 1 Reply
- 2 Participants
-
DT Dinesh Theetla
- Oct 12, 2015 02:01 PM UTC
- Oct 13, 2015 10:16 AM UTC