Changes between Version 1 and Version 2 of AlphaSort


Ignore:
Timestamp:
01/17/10 19:00:29 (15 years ago)
Author:
Fran Boon
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • AlphaSort

    v1 v2  
    1010This one is a Database one using the IS_ONE_OF() custom validator from {{{modules/validators.pty}}}
    1111
    12 js list sorter:
     12Massimo 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
     17Foront-end soring can be done with JS:
    1318 * 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>
     22jQuery(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}}}
    1432
    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]]
     33Q: Where does one put page-specific Javascript ?[[BR]]
    1934A: {{{views/module/resource_method.html}}}
    2035
    21 For Dictionary-based ones:
     36For Dictionary-based ones can:
    2237{{{
    2338In  models/05_or.py change: