Solved

How to do the Date format in ui-grid

Posted on 2016-09-24
7
39 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

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.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

776 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