Having a N/A as default value in Date column sorting not working properly

Having a N/A as default value in Date column sorting not working properly

gsolai007gsolai007 Posts: 3Questions: 2Answers: 0

{ data : "Effective_Date_ACE__c", defaultContent: "N/A", render: function (data) {
if(data != null ) {
var formatdate = moment(data).add(1, 'days').format('MM/DD/YYYY');
return formatdate;
}
}, className: "CustomDataFont" },

Answers

  • SchautDollarSchautDollar Posts: 21Questions: 6Answers: 1

    The issue is defaultContent won't be used since you have "render" defined.
    Reference: https://datatables.net/reference/option/columns.render

    Since you have render defined, just add your "default" behavior in there.

    Example:

    { 
        data : "Effective_Date_ACE__c", 
        render: function (data) {
            if(data != null ) {
                var formatdate = moment(data).add(1, 'days').format('MM/DD/YYYY');
                return formatdate;
            }else{
                 return "N/A";
            }
        }, 
        className: "CustomDataFont" },
    

    I haven't tested it, but this should do what you want it to do.

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Hi @gsolai007 ,

    The best bet would be to not use default content, but change the global value - see example here (look at Ashton Cox). This solution came from this thread here.

    Cheers,

    Colin

  • gsolai007gsolai007 Posts: 3Questions: 2Answers: 0

    Thanks @colin

This discussion has been closed.