alfajango / jquery-dynatable

A more-fun, semantic, alternative to datatables
http://www.dynatable.com
Other
2.78k stars 363 forks source link

Sort is not working propery #292

Closed msaus closed 6 years ago

msaus commented 6 years ago

Hello forks,

It seems to me that sort function is not working at all.

jquery 1.11.1 dynatable 0.3.1

Dose anyone know how to fix that?

msaus commented 6 years ago

I could solve myself like following.

$('#ranking-detail'+id).bind('dynatable:init', function(e, dynatable) {                                                              
  }).dynatable({                                                                                                                       
    features: {                                                                                                                        
      paginate: false,                                                                                                                 
      search: false,                                                                                                                   
      perPageSelect: false,                                                                                                            
      recordCount: false                                                                                                               
    },                                                                                                                                 
    readers:{                                                                                                                          
      '順位' : function(el, record){                                                                                         
        return parseInt(el.innerHTML);                                                                                                 
      },                                                                                                                               
      '数' : function(el, record){                                                                                                 
        return parseInt(el.innerHTML);                                                                                                 
      },                                                                                                                               
      'ランキング' : function(el, record){                                                                                     
        return  parseInt(el.innerHTML);                                                                                                
      },                                                                                                                               
    },                                                                                                                                 
    writers: {                                                                                                                         
      'ランキング': function(record) {                                                                                         
        return record['ランキング'] ? record['ランキング'].toString() + '位' : 'n/a';                                  
      },                                                                                                                               
      '順位': function(record) {                                                                                             
        return record['順位’] ? record['順位'].toString() + '位' : 'n/a';                                          
      }
    }
  });
msaus commented 6 years ago

Possibly, you need a doc for this.