Solved

How to do the Date format in ui-grid

Posted on 2016-09-24
7
43 Views
Last Modified: 2016-11-13
Hi,  I tried this and it is not working for me. Dates are now displayed as 2015-02-03T05:49:54.850Z. Any suggestions plz.
$scope.gridOptions = {
data: 'mydata',
enableRowSelection: true,
multiSelect: false,
enableColumnResize: true,
columnDefs: [
{ field: 'startDate', displayName: 'Date',type: 'date', cellFilter: 'date:\'yyyy-MM-dd\'' }]};

Open in new window



Thanks
0
Comment
Question by:KavyaVS
  • 3
  • 3
7 Comments
 
LVL 23

Assisted Solution

by:Ioannis Paraskevopoulos
Ioannis Paraskevopoulos earned 100 total points
ID: 41814645
Which version of ui-grid are you using?
If you are using the latest, you should also provide a name for each columnDef.

Do you get any errors in the console??

Giannis
0
 
LVL 27

Expert Comment

by:BigRat
ID: 41814664
These are the options for the Grid, the Grid itself will be made (I hope) from an HTML template. Can you post the template? Or are you using a standard grid?
0
 

Author Comment

by:KavyaVS
ID: 41815253
I am using version 3 .In the module declaration I am injecting [ui.grid] .I am not getting any console errors.

I already posted the code I am using for Date formatting.But is is not working. Dates are displaying as 2015-02-03T05:49:54.850Z. But I want it as yyyy-MM-dd with out any time zone,hours,mins etc., Thanks
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 27

Assisted Solution

by:BigRat
BigRat earned 400 total points
ID: 41815835
What do you have as data? The docs say that it must be a Date object, amongst others. But if the Javascript "variable" in the data is a string, then the type must be string and not date.
0
 

Author Comment

by:KavyaVS
ID: 41820363
I tried the type as string. But still not working.
0
 
LVL 27

Accepted Solution

by:
BigRat earned 400 total points
ID: 41841692
I'd really like to see the data source, but I suspect that it is a string. It is very important to know EXACTLY what we are dealing with in order to get the correct filter.

See http://brianhann.com/6-ways-to-take-control-of-how-your-ui-grid-data-is-displayed/ for example!
0
 

Author Closing Comment

by:KavyaVS
ID: 41885324
Thanks
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction JSON is an acronym for JavaScript Object Notation.  It is a text-string data transport mechanism, capable of representing simple or complex data structures in a consistent and easy-to-read manner.  Similar in concept to XML, but more e…
You have this traditional web application that refreshes the whole page each time you navigate and you think it's a good time to convert it to a Single-Page approach. What should you know in advance? Read on, I'll guide you through it.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

860 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