1

I am using ng-grid from following link:http://angular-ui.github.io/ng-grid/

My MVC Controller function return data in json format which includes date like this

: "RunDate":"\/Date(1439577000000)\/","RunDate":"\/Date(1441391400000)\/" etc....

My View:

<div ng-grid="gridOptions" style="min-height:420px"></div>

My Grid options in js:

$scope.gridOptions = {
        data: 'myData',
        enablePaging: true,
        showFooter: true,
        columnDefs: [{ field: "RunDate", displayName: "Run Date", width: 120, cellFilter: "date:'yyyy-MM-dd'" }],
        totalServerItems: 'totalServerItems',
        pagingOptions: $scope.pagingOptions,
        filterOptions: $scope.filterOptions
    };

I want date to be display in this format:06/April/2015

Can anybody help me with this???

I Love Stackoverflow
  • 6,738
  • 20
  • 97
  • 216

3 Answers3

2

Use Angular date filter, like this:

{{row.entity.RunDate | date:'dd-MMM-yyyy'}}
IndieTech Solutions
  • 2,527
  • 1
  • 21
  • 36
Reena
  • 1,109
  • 8
  • 16
2

You need to apply custom filter on you variable while binding data. Do use cellTemplate of column level.

Code

 $scope.gridOptions = {
 data: 'gridData',
 columnDefs: [{
         field: 'RunDate',
         displayName: 'Run Date',
         cellTemplate: '<span> {{row.entity.RunDate | date:\'dd-MMM-yyyy\'}}</span>',
     },
     ....
 ]
 });
Pankaj Parkar
  • 134,766
  • 23
  • 234
  • 299
1

You need to change the date formatting on your gridOptions The correct date format you need is

dd/MMM/yyyy

 $scope.gridOptions = {
        data: 'myData',
        enablePinning: true,
        columnDefs: [
                     { field: 'RunDate',displayName: 'Run Date', cellFilter: 'date:\'dd/MMM/yyyy\'' },
                   ]
    };
   ...........
});

Check this link for an example

IndieTech Solutions
  • 2,527
  • 1
  • 21
  • 36