1

I am working on wijgrid inside the column tags I want to set the date field.

My data is coming from JSON (Date's inside the table columns) but my date format is 2012-07-24T14:03:24.000+0000 and I want my date format should be like this 2012-07-24.

I tried dataType: "datetime" inside the columns but its instead of showing it is hiding from the columns(columns are displaying empty)

This is my code :

$("#deviceloglist")
     .wijgrid({
        pageSize : 5,
        allowPaging : true,
        allowSort: true,
        allowfilter:true,
columns: [ { headerText : "Created Date" ,dateFormat: 'd'
    },{ headerText : "Details"}, { headerText : "CreatedBy"},
    { headerText : "LogType", visible:false}, { headerText : "LogData",visible:false}
],
Tina
  • 25
  • 2
  • 10
  • You may find some of the information here (http://stackoverflow.com/questions/2479714/does-javascript-ecmascript3-support-iso8601-date-parsing) useful. – dnagirl Aug 14 '12 at 15:22

1 Answers1

0

You can simply use a substring that will first find out where is the letter "T".

Here is a test sample :

var test = "2012-07-24T14:03:24.000+0000";
alert(test.substr(0,test.indexOf("T")));

.indexOf("T") returns 10. Then we use it to cut the string from char 0 to 10.

Gil Zumbrunnen
  • 1,062
  • 6
  • 17
  • my data is coming from JSON and I am working on client site...so I couldn't not apply this code.I have only that columns option to update and change the format...Could you explain the code for that?..Thanks Tina – Tina Aug 17 '12 at 05:44
  • My answer is javascript, client side. Do you want to apply it in your DB or you just need to display it nicely? Your data can be JSON, can be a string, can be even xml it doesn't matter you have full control over it. All you care about is to either change it through js BEFORE sending it to your plugin, or use jQuery AFTER to target what you want to change in your DOM. Doing it before is always better practice, if you don't know how to access this string in your JSON you can update your question to show its structure. – Gil Zumbrunnen Aug 17 '12 at 06:13
  • I never used your grid plugin but you have empty columns with dataType probably because it's expecting a Date object, not a string. Or a well formated string not any. – Gil Zumbrunnen Aug 17 '12 at 06:17
  • actually,There is simple wijmo code and to get the JSON table in UI(I have columns inside that grid and one of them is for date (where date formate is "2012-07-24T14:03:24.000+0000" and I want "2012-07-24")) ...I tried to change the data type as mention in wijmo documentation inside the columns but it is actually hiding the date from the columns ....I don't know the other way of resolving the issue. – Tina Aug 17 '12 at 06:28
  • So, tell me if I'm wrong, but you're probably getting data from your server with AJAX as JSON, and then you do what you have to do with that JSON before sending it to your wijmo plugin. All I need to help you is either to see how that JSON looks like, or you have a pure html table in your page and this plugin is probably using it to change the way it will be displayed. So show me either your table or your JSON. – Gil Zumbrunnen Aug 17 '12 at 07:26
  • If you're working in an array, use a Javascript "for" loop. If you're working in a map you can use $.each() from jQuery. You will have to loop through all elements you want to modify and update its string. – Gil Zumbrunnen Aug 17 '12 at 10:34
  • 1
    Thank you very much gil ...your code is perfect!! I just need to pass this code inside the mapping through the function and I am done. mapping: function (item) { var test = item.createdDate; return test.substr(0,test.indexOf("T")); – Tina Aug 21 '12 at 10:52
  • @gill: Gill,I have some update on date formate....Now I want to change my ISO date formate in (date and time (2012-08-31T08:05:00))...can you please guide me ...how to do that..? Thanks Tina!! – Tina Sep 03 '12 at 13:05
  • 1
    Change the .indexOf("T") into .indexOf(".") – Gil Zumbrunnen Sep 03 '12 at 13:39
  • :Thank you very much gil..but gill its showing in the format(2012-09-03T09:32:54) and I don't want T...can we remove T from here and only date and time will come at grid...? Thanks Tina!! – Tina Sep 04 '12 at 05:26
  • Gill I also want to ask you for one more column in grid...I have two columns in grid (one is for date and other is for modified date) so I have given same code to both for converting date formate....but my modified date is not accepting indexof..can v resolve this also ....Below is the code : name : "modifieddate", mapping: function (item) { var test = item.modifieddate; return test.substr(0,test.indexOf("T"));} – Tina Sep 04 '12 at 05:30
  • Just replace your T with a space .replace("T"," "); But Tina I think you need to review the basics by following a tutorial or ask for professional help. Buying a Wijmo licence doesn't make you a developer. – Gil Zumbrunnen Sep 04 '12 at 07:35
  • @hi gil : I need your help...I want to change my GMT time to Indian local format...can you please tell me how do I replace gmt to indian local format ..? Thanks Tina!! – Tina Sep 14 '12 at 05:20
  • I want to convert GMT time to current user's browser time. – Tina Sep 14 '12 at 05:47