javascript - Sorting issue with plain text and html in the same column using Handsontable -


i'm having problem sorting column contains plain text html anchor tag. sorting seems occurring on value stored in data source array rather displayed value. cells containing anchor tag sorted above plain text cells.

below jsfiddle example. third column sort alphabetically names regardless of whether cell contains anchor tag or plain text.

example: http://jsfiddle.net/5sl2jkqt/

{ data: 2, renderer: "html" } 

i tried applying custom cell renderer on third column did not help. suggestions on how around appreciated!

what did around add following function handsontable.full.js

  // strip out tags not in allowed parameter   function striptags(input, allowed) {        if (!input) {           return "";       } else if (!isnan(input)) {           return input;       }        // making sure allowed arg string containing tags in lowercase (<a><c>)       allowed = (((allowed || "") + "").tolowercase().match(/<[a-z][a-z0-9]*>/g) || []).join("");         var tags = /<\/?([a-z][a-z0-9]*)\b[^>]*>/gi,           commentsandphptags = /<!--[\s\s]*?-->|<\?(?:php)?[\s\s]*?\?>/gi;         return input.replace(commentsandphptags, "").replace(tags, function ($0, $1) {            return allowed.indexof("<" + $1.tolowercase() + ">") > -1 ? $0 : "";        });     }; 

i called striptags function in native handsontable function this.sort adds content sorting array this.sortindex following:

this.sortindex.push([i, striptags(instance.getdataatcell(i, this.sortcolumn + coloffset), "")]); 

not 100% ideal worked charm. strips out html , sorts on left over.

can found on github


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -