我做什麼來解決這個問題是下面的函數添加到handsontable.full.js
// Strip out all tags not in the allowed parameter
function stripTags(input, allowed) {
if (!input) {
return "";
} else if (!isNaN(input)) {
return input;
}
// making sure the allowed arg is a string containing only 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 : "";
});
};
我當時稱爲在本地handsontable功能this.sort的stripTags功能,增加了你正在排序的數組this.sortIndex如下:
this.sortIndex.push([i, stripTags(instance.getDataAtCell(i, this.sortColumn + colOffset), "")]);
不是100%的理想,但工作像一個魅力。它去掉HTML並對剩餘的內容進行排序。
也可以在GitHub上找到