I am using kendo grid where I have added a column of DateTime type which shows datetime.
The problem which I am facing is that if their is no date set then by default it is showing null
value.
What I want is that if no date is set then it should show blank cell value instead of null.
I am using 2012.2.710.340
version of kendo.
Have declare the field value in class in following way :
public DateTime? Time { get; set; }
Below is the format I have used in kendo grid to show datetime field in grid :
columns.Bound(o => o.Time).Format("{0:MM/dd/yyyy HH:mm:ss}").Title("Time");
I will be thankful if anyone could help me out in solving my problem.
I have tried using kendo.tostring in following way:
columns.Bound(o => o.Time).ClientTemplate("#= (Time == null) ? ' ' : kendo.toString(Time, 'MM/dd/yyyy HH:mm:ss') #").Title("Time");
By applying the above code my problem gets solved but because of this filters in the kendo grid stop working. I want that filters should work inspite of having blank value for datetime field in the grid if datetime is not set.
try this
columns.Bound(o => string.IsNullOrWhiteSpace(o.Time)?string.Empty:o.Time).Format("{0:MM/dd/yyyy HH:mm:ss}").Title("Time");
or use the column template to render the date.
<script type="text/x-kendo-template" id="TimeTemplate">
# var date = time === null ? '': time ;#
#=date#
</script>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With