'data is null' error

'data is null' error

mihalispmihalisp Posts: 127Questions: 22Answers: 0

Hi everyone,
I get the field "Hours" from the DB ,but i want to render it so that it gets another value if the value of another column (other_column_id) is '6500'.
But i always get error 'data is null'.
Can anyone help?
Are these 3 conditions (null,'','undefined') always necessary-right to use when to check for null values?

  { "data": "Hours" , "title": "Hours" ,  "render":  function (data, type, row) {
    if ((data != null) || (data != '') || (data != 'undefined')){
        if ((data.other_column_id != null) || (data.other_column_id != '') || (data.other_column_id != 'undefined')) {
            if (data.other_column_id == 6500) { return '6500' ;}
            else {return data;} }
        else {return data;} 
   }
   else {return null;}
  }
  }

Thank you.

Answers

  • kthorngrenkthorngren Posts: 20,144Questions: 26Answers: 4,736

    But i always get error 'data is null'.

    You get an error message with 'data is null'? Please post the exact message.

    Are these 3 conditions (null,'','undefined') always necessary-right to use when to check for null values?

    That depends on your data. Do you have null values in your data? And are you trying to not display them if you do?

    I'm not clear on what you are trying to do but suggest you use console.log statements in your render function to get an understanding of what its doing so yo can change it to meet your needs. Otherwise we will need a test case with an example of your data to help.

    Kevin

  • mihalispmihalisp Posts: 127Questions: 22Answers: 0

    Yes,i always get this error TypeError:data is null.
    Yes,i have NULL values which i want to display as NULL or ' '.
    Al these columns have some NULL values

    I think i have used all the conditions i could have used here.What am i missing?

  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin

    Yes,i have NULL values which i want to display as NULL or ' '.

    Try using:

    "render":  function (data, type, row) {
      if ( data === null ) {
        return '';
      }
      else {
        ...
      }
    }
    

    Allan

  • kasunclementkasunclement Posts: 1Questions: 0Answers: 0

    use default content to handle null values

    "data": " ",
    "defaultContent": "-----"

Sign In or Register to comment.