Skip to content

Commit

Permalink
HUE-24. Filesize Sorting doesn't work
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcus McLaughlin committed Jul 13, 2010
1 parent 4943335 commit aaad889
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 6 deletions.
Expand Up @@ -88,13 +88,17 @@ from django.template.defaultfilters import urlencode, stringformat, filesizeform
% endif
</div>
</td>
<%
if "dir" == file['type']:
sortValue = 0;
else:
sortValue = file['stats']['size']
%>
<td class="fb-filesize">
% if "dir" == file['type']:
##this hidden zero is for sorting
<span style="display:none">0</span>
~
<span data-sort-value="${sortValue}">~</span>
% else:
${file['stats']['size']|filesizeformat}
<span data-sort-value="${sortValue}">${file['stats']['size']|filesizeformat}</span>
% endif
</td>
<td class="fb-user">${file['stats']['user']}</td>
Expand Down
Expand Up @@ -17,12 +17,35 @@
---
description: Creates instances of HtmlTable for any table with the css class .ccs-data_table with additional options for sortability and selectability.
provides: [CCS.JFrame.HtmlTable]
requires: [/CCS.JFrame, More/HtmlTable.Sort, More/HtmlTable.Zebra, More/HtmlTable.Select]
requires: [/CCS.JFrame, More/HtmlTable.Sort, More/HtmlTable.Zebra, More/HtmlTable.Select, /Element.Data]
script: CCS.JFrame.HtmlTable.js
...
*/

//The newHash here is used to attach these parsers at the beginning of the HtmlTable.Parsers hash. Otherwise, anything that begins with a number is picked up by the 'number' parser, which is not what we want.
newHash = new Hash();
//A parser to allow numeric sorting by any value.
newHash.dataSortValue = {
match: /data-sort-value/,
convert: function() {
text = this.getElement('[data-sort-value]').get('data', 'sort-value');
return text.toInt();
},
number: true
};
//A parser to allow lexicographical sorting by any string.
newHash.dataSortString = {
match: /data-sort-string/,
convert: function() {
text = this.getElement('[data-sort-string]').get('data', 'sort-string');
return text;
},
number: false
};
newHash.combine(HtmlTable.Parsers);
HtmlTable.Parsers = newHash;

CCS.JFrame.addGlobalFilters({

htmlTable: function(container){
Expand Down Expand Up @@ -71,4 +94,8 @@ CCS.JFrame.addGlobalFilters({
}
}

});
});




0 comments on commit aaad889

Please sign in to comment.