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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Replace null default values with a default string

Thread ID:





127681 Dec 2,2016 09:37 AM UTC Dec 12,2016 05:43 AM UTC JavaScript 3
Tags: ejGrid
Stephen Abel
Asked On December 2, 2016 09:37 AM UTC


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?



Seeni Sakthi Kumar Seeni Raj [Syncfusion]
Replied On 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. 

Stephen Abel
Replied On December 8, 2016 12:46 PM UTC

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

Mohammed Farook J [Syncfusion]
Replied On December 12, 2016 05:43 AM UTC

Hi Stephen, 
Thanks for updated. 
J.Mohammed Farook 


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon