Wijmo 5 [Flex Grid]
Custom Sorting with Null value accounting in sorting
by Manish Gupta
HTML
<link rel="stylesheet" href="http://cdn.wijmo.com/5.20162.198/styles/wijmo.min.css">
<script src="http://cdn.wijmo.com/5.20162.198/controls/wijmo.min.js"></script>
<script src="http://cdn.wijmo.com/5.20162.198/controls/wijmo.input.min.js"></script>
<script src="http://cdn.wijmo.com/5.20162.198/controls/wijmo.grid.min.js"></script>
<script src="http://cdn.wijmo.com/5.20162.198/interop/angular/wijmo.angular.min.js"></script>
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<div ng-app="app" ng-controller="appCtrl">
<wj-flex-grid items-source="data" style="width:500px;" >
<wj-flex-grid-column header="Type" binding="type" >
</wj-flex-grid-column>
<wj-flex-grid-column header="Name" binding="name" width="*"></wj-flex-grid-column>
</wj-flex-grid>
</div>
JavaScript
var data = [
{ name: 'AAAx', type: 10 },
{ name: 'Excel Import 10 accounts.xlsx', type: null },
{ name: 'Assets', type: -2 },
{ name: 'Income Statement', type: 7 },
{ name: 'Liabilities and Equity', type: null },
{ name: 'Permanent', type: 8 },
{ name: 'General', type: 0},
{ name: 'WW.docx', type: null },
{ name: 'Untitled.pdf', type:0}
];
var app = angular.module('app', ['wj']);
app.controller('appCtrl', function ($scope) {
$scope.data = new wijmo.collections.CollectionView(data);
//$scope.dataMap= new wijmo.grid.DataMap(data,'name','name')
$scope.data.sortConverter = function (sd,item,value) {
if (sd.property == 'type' && item.type==null ) {
value=-99999;
}
return value;
};
});