mRender not working ?

mRender not working ?

sreenu539sreenu539 Posts: 10Questions: 2Answers: 0
edited August 2014 in Free community support

The following is the code and it is going into mRender function but value still displayed is "1" or "0" NOT "Yes" or "No". datatables version is 1.10

I am getting 1 or 0 from server side and need to display yes or no front end.

  "aoColumns": [
      { "mData": "name" },
      { 
        "mData": "Flag" ,
        "mRender": function ( data, type, full ) {
                    if(data === "1") {
                       return "Yes";
                    } else {
                        return "No";
                    }

        }                   
    }
    ],

EDIT : I found out that search HIGHLIGHT function is overriding the data returned from mRender.

Is there any example of HIGHLIGHT function that works with "mData" or " manipulated display" of data.

Here is the search HIGHLIGHT function code snippet that used to highlight the data when "mData" used.

jQuery('td', nRow).each( function(i) {
                    /* Take into account that ColVis may be in use

                        var j = oApi._fnVisibleToColumnIndex( oSettings,i);

                    Only try to highlight if the cell is not empty or null
                     */
                    var colProp = oSettings.aoColumns[i].mData;

                if (aData[colProp] !== undefined && aData[colProp] !== null && aData[colProp] !== "") {
                        // If there is a search string try to match
                        if ((typeof sSregex !== 'undefined') && (sSregex)) {
                            var mapObj = {
                                            '®' : "\u00AE",
                                            '™' : "\u2122",
                                            '"'  : "\u201C",
                                            ' '  : " "
                                        };
                                        aData[colProp] = aData[colProp].replace(/(®)|(™)|(")|( )/gi, function(matched){
                                            return mapObj[matched];
                                        }); 
                            this.innerHTML = aData[colProp].replace( regex, function(matched) {
                                return "<span class='filterMatches'>"+matched+"</span>";
                            });
                        }

                        else {
                            this.innerHTML = aData[colProp];
                        }
                    }
                });
This discussion has been closed.