This question is locked. New answers and comments are not allowed.
I am trying to apply a format to a date so if the Date == DateTime.Min basically I don't want to show anything, just blank or 'nbsp;'.
This worked with my client side databinding but now that I have added AJAX binding it doesn't seem to work with it. It ends up showing NaN/NaN/NaN
Here is my column:
And the function:
This worked with my client side databinding but now that I have added AJAX binding it doesn't seem to work with it. It ends up showing NaN/NaN/NaN
Here is my column:
columns.Bound(o => o.MyDate).Title("My Date").Width("15%").ClientTemplate("<#= formatDateTime(MyDate) #>");
And the function:
function formatDateTime(value) { var date = (Object.prototype.toString.call(value) === '[object Date]') ? new Date(value) : new Date(parseInt(value.substr(6))); // json type var curr_date = date.getDate(); if (curr_date < 10) curr_date = '0' + curr_date; var curr_month = date.getMonth(); curr_month++; if (curr_month < 10) curr_month = '0' + curr_month; var curr_year = date.getFullYear(); var datestring = curr_month + "/" + curr_date + "/" + curr_year; if (curr_year <= 1) datestring = ' '; return datestring; }