Renderer not passing through the if condition for a date filed

Renderer not passing through the if condition for a date filed

InnocentmInnocentm Posts: 11Questions: 3Answers: 0
edited August 2018 in Free community support

Am trying to display blank for null or '1971-01-01' fields in my DB but the if block does not get executed

{ data: "eta", 
render: function ( data, type, row ) {
                  if (data =='1971-01-01') {
                    return '';
                    }
                  else {
                    return data;
                    }
                }
            },

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,302Questions: 26Answers: 4,947
    edited August 2018

    Hard to say wihtout seeing your data. Maybe you can add a console.log command to see what data actually is:

    render: function ( data, type, row ) {
                      console.log('"' + data + '"');
                      if (data =='1971-01-01') {
    

    Kevin

  • InnocentmInnocentm Posts: 11Questions: 3Answers: 0

    Below is my data

  • kthorngrenkthorngren Posts: 21,302Questions: 26Answers: 4,947
    Answer ✓

    I don't see 1971-01-01 in the data you posted above. Maybe you want 1970-01-01 instead?

    Kevin

  • InnocentmInnocentm Posts: 11Questions: 3Answers: 0
    edited August 2018

    Thanks Kevin, I have also just spotted that now. It's working!!

This discussion has been closed.