We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Replace null default values with a default string


In a grid control I receive a nullable date field. For the null values, rather than just displaying a blank cell, is there a way of setting a default value so it could display something like 'No date supplied' instead?



3 Replies

SS Seeni Sakthi Kumar Seeni Raj Syncfusion Team December 5, 2016 01:44 PM UTC

Hi Stephen, 
You can use the queryCellInfo event of the Grid to modify any cells in the Grid. Therefore, for a null date values, you can use the queryCellInfo event and format the cells.  
Based on the type of the column and values present in the current cell, text of the particular has been replaced. Refer to the following code example and API Reference. 
<div id="Grid"></div> 
<script type="text/javascript"> 
    $(function () { 
        var data = [ 
            { OrderID: 10248, OrderDate: new Date() }, 
            { OrderID: 10249, OrderDate: null }, 
            { OrderID: 10250, OrderDate: "" } 
            dataSource: data, 
            allowPaging: true, 
            queryCellInfo: function (args) { 
                if (args.column.type == "date" || args.column.type == "datetime") { 
                    var val = ej.getObject(args.column.field, args.data); 
                    if (ej.isNullOrUndefined(val) || val == "") 
                        $(args.cell).text("No Date Supplied"); 
            columns: [ 
                { field: "OrderID" }, 
                { field: "OrderDate", format: "{0:MM/dd/yyyy}" } 
We have prepared a sample that can be referred from the following jsPlayground. 
Seeni Sakthi Kumar S. 

SA Stephen Abel December 8, 2016 12:46 PM UTC

Thank you - that is exactly what I was looking for.

MF Mohammed Farook J Syncfusion Team December 12, 2016 05:43 AM UTC

Hi Stephen, 
Thanks for updated. 
J.Mohammed Farook 

Live Chat Icon For mobile
Up arrow icon