[table] use cell text content when cubicweb:sortvalue is not defined (closes #2093183)
authorAdrien Di Mascio <Adrien.DiMascio@logilab.fr>
Fri, 16 Dec 2011 14:35:20 +0100
changeset 8129 2dedcc15208d
parent 8128 0a927fe4541b
child 8130 85ade620056c
[table] use cell text content when cubicweb:sortvalue is not defined (closes #2093183)
web/data/cubicweb.js
--- a/web/data/cubicweb.js	Fri Dec 16 12:30:12 2011 +0100
+++ b/web/data/cubicweb.js	Fri Dec 16 14:35:20 2011 +0100
@@ -84,11 +84,13 @@
     },
 
     sortValueExtraction: function (node) {
-	var sortvalue = jQuery(node).attr('cubicweb:sortvalue');
-	if (sortvalue === undefined) {
-	    return '';
-	}
-	return cw.evalJSON(sortvalue);
+        var $node = $(node);
+        var sortvalue = $node.attr('cubicweb:sortvalue');
+        // No metadata found, use cell content as sort key
+        if (sortvalue === undefined) {
+            return $node.text();
+        }
+        return cw.evalJSON(sortvalue);
     }
 });