Show empty cell value for datetime field in Kendo grid?

I use the kendo grid, where I added a column of type DateTime that shows the date and time.

The problem I am facing is that if there are none, then by default it shows the value null.

I want that if the date is not set, it should show an empty cell value instead of zero.

I am using kendo version 2012.2.710.340.

Declare a field value in a class as follows:

public DateTime? Time { get; set; }

Below is the format I used in the kendo grid to display the datetime field in the grid:

columns.Bound(o => o.Time).Format("{0:MM/dd/yyyy HH:mm:ss}").Title("Time");

I will be grateful if anyone can help me solve my problem.

+4
source share
3

kendo.tostring :

columns.Bound(o => o.Time).ClientTemplate("#= (Time == null) ? ' ' : kendo.toString(Time, 'MM/dd/yyyy HH:mm:ss') #").Title("Time");

, , - kendo . , datetime , - .

+6

columns.Bound(o => string.IsNullOrWhiteSpace(o.Time)?string.Empty:o.Time).Format("{0:MM/dd/yyyy HH:mm:ss}").Title("Time"); 

.

<script type="text/x-kendo-template" id="TimeTemplate">
     # var date = time === null ? '': time ;#
    #=date#

</script>
+2
 columns.Bound(r => r.AssignedDate).ClientTemplate("#= AssignedDateFormat(data) #").Title("Assigned Dt").Width("40px"); 

function AssignedDateFormat(param) {
    var html;
    if (param.AssignedDate == null) {
        html = ""; 
    }
    else {
        html = kendo.toString(param.AssignedDate, 'MM/dd/yyyy');
    }

    return html;
}
0
source

All Articles