* use $.tablesorter.addParser whenever you can. It is useful cause in examples you can find on Tablesorter documentation all examples handle with plain text in cells. In my case I had few spans, images and so on as a content of span.
*In format property of addParser you define what should be done when content of cell is available. Since I like to use jQuery I realize that jQuery is not appliable to content I get. So weird and so strange. After sometime I got it! jQuery requests root html element and content you get from parameter in format function doesn't have root element. So, in order to get content workable with jQuery create something like this
var innerContent = $("<
$.tablesorter.addParser({
id: 'currencySwiss',
is: function(s) {
return false;
},
format: function(s) {
var innerContent = $("<root>" + s + "< /root>");
if (isElectronicProduct === 'False') {
if ($("span[id$='ctlNetPriceMediaLabel']", innerContent)[0].innerHTML === "") {
return 10000000;
} else {
return $("span[id$='ctlNetPriceMediaLabel']", innerContent)[0].innerHTML;
}
} else {//electronic product
if ($("span[id$='ctlNetPriceLabel']", innerContent)[0].innerHTML === "") {
return 10000000;
} else {
return $("span[id$='ctlNetPriceLabel']", innerContent)[0].innerHTML;
}
}
},
type: 'numeric'
});
Cheers,