Changes between Version 1 and Version 2 of AlphaSort
- Timestamp:
- 01/17/10 19:00:29 (15 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
AlphaSort
v1 v2 10 10 This one is a Database one using the IS_ONE_OF() custom validator from {{{modules/validators.pty}}} 11 11 12 js list sorter: 12 Massimo has put back-end sorting into [http://bazaar.launchpad.net/~mdipierro/web2py/devel/revision/1543 Trunk]: 13 * IS_IN_SET(...,sort=True) and/or IS_IN_DB(...,sort=True) 14 * needs porting to IS_ONE_OF() 15 * needs testing 16 17 Foront-end soring can be done with JS: 13 18 * http://stackoverflow.com/questions/278089/javascript-to-sort-contents-of-select-element/278509#278509 19 * This works with capitalised/non merged but means that the NULL in IS_NULL_OR() isn't the default: 20 {{{ 21 <script> 22 jQuery(document).ready(function(){ 23 jQuery("select").each(function(){ 24 jQuery(this).html(jQuery(this).children("option").sort(function(a,b) { 25 return (a.text.toUpperCase() == b.text.toUpperCase())?0:((a.text.toUpperCase() < b.text.toUpperCase())?-1:1); 26 })); 27 // jQuery(this).children("option:first").attr("selected","selected"); 28 }); 29 }); 30 </script> 31 }}} 14 32 15 As far as sorting right in the backend is concerned - models/05_or.py line 107, tried putting .select(orderby = db.or_organsation.name)[0]... 16 But that did not work out... 17 18 Q: If its possible to put a javascript fix where does one put a page specific js ?[[BR]] 33 Q: Where does one put page-specific Javascript ?[[BR]] 19 34 A: {{{views/module/resource_method.html}}} 20 35 21 For Dictionary-based ones :36 For Dictionary-based ones can: 22 37 {{{ 23 38 In models/05_or.py change: