Empty Data handling

Empty Data handling

al_1976al_1976 Posts: 9Questions: 3Answers: 0

I have two cells of data. If one is empty, the other one will have a value. Only one will have a value at any time. The psudeo code below is an example of what I would like to do

"columns": [

        { "data": "InformationAssetId" },
        { "data": "CommunicationDate" },
        { "data": "DocumentFullFillmechanism", function (data}{
        if (data.length < 1){
                {"data": "thisDataInstead"}
        }

},
{ "data": "CommunicationSubject" },
{ "data": "CustomerViewable" },
{ "data": "DocumentId" }
{ "data": "AgreementReference"},
]

Many Thanks

Answers

  • tangerinetangerine Posts: 3,350Questions: 37Answers: 394

    You could use a "render" function.

    https://datatables.net/reference/option/columns.render

  • al_1976al_1976 Posts: 9Questions: 3Answers: 0

    Thanks but if I use the render function and the data is empty it throws an error :-(

  • al_1976al_1976 Posts: 9Questions: 3Answers: 0

    Apologies to tangerine. The render function does work prefectly for this. My brain obviously doesn't ! Here is my solution in case anyone is in a similar position

    { "data": "AgreementReference", "render" : function (data,type,row,meta){

                var noData = row.PortalAccountId ;
                var thisData = data
    
                if (data.length < 1){
                return noData 
                }
                else{
                 return thisData 
                }
    
            }},
    
This discussion has been closed.