Working with dates as a string and number

In this JSFiddle https://jsfiddle.net/txhi/arzc09o6/

Everything works fine when I use the drop down menu from the combo box. I can see unix dates because in the JSON data, I am feeding dates as string and this function is parsing it to Int :

geteditorvalue: function (row, cellvalue, editor) {
      // return the editor's value.
      return new Date(parseInt(editor.val()));
    },

However, in this JSFiddle, https://jsfiddle.net/3hewLd84/6/

I am passing dates as numbers and I modified this function by removing parseInt as follows:

geteditorvalue: function (row, cellvalue, editor) {
      // return the editor's value.
      //alert(editor.val());
      return new Date(editor.val());
    },

But I am seeing blank when I use the combo box to see anything. Why is it like this?

are you sure about that?

  //alert(editor.val());

=>
alert(typeof editor.val());

Hey @m_hutley, Good point. I think it’s not a number. From the Java web service I am getting a timestamp and that’s what is returning in the JSON and I am grabbing this value in Javascript. When I used alert(typeof editor.val());, I got undefined in the alert .

Do you think that I should make my Java webservice to return it as a string and the convert it to number while using in Java Script? Thanks

When i do alert(typeof editor.val()); in your second codepen, I get string.

Hmm, I got undefined in 2nd JSFiddle when I did the following:

geteditorvalue: function (row, cellvalue, editor) {
      // return the editor's value.
      //alert(editor.val());
      alert(typeof editor.val());
      return new Date(editor.val());
    },

Here is modified fiddle:

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.