2013-07-24 3 views
0

내 웹 사이트에 데이터 테이블이 있고 1,999,999,999로 숫자 정렬을 시도하지만 작동하지 않습니다. Google에서 많은 팁으로 문제를 해결하려고했지만 도움이되지 않습니다.데이터 정렬 정렬 번호가 작동하지 않습니다.

내 테이블 여기

$('.d3uitems').dataTable({ 
     "bJQueryUI": true, 
     "sPaginationType": "full_numbers", 
     "sDom": '<""l>t<"F"p>', 
     'aaSorting': [[ 0, 'desc' ]] 
    }).columnFilter({ 
      aoColumns: [ null, 
        { type: "text"}, 
         null, 
        null, 
        { type: "text"}, 
        null 
       ] 
    }); 

내가 숫자를 정렬하려고 어디에 데이터 테이블입니다위한 자바 스크립트 코드를 이잖아.

http://www.lootfinder.net/index.php?page=d3uitems

답변

1

당신은 그것을 시도 할 수있다 "는,"우리는 DataTable의 정렬 기능을 덮어 및 대체합니다.

<script type="text/javascript" charset="utf-8"> 

     jQuery.fn.dataTableExt.oSort['numeric-comma-asc'] = function(a,b) { 
      var x = (a == "-") ? 0 : a.replace(/,/g,""); 
      var y = (b == "-") ? 0 : b.replace(/,/g,""); 
      alert("x=" + x); 
      x = parseFloat(x); 
      y = parseFloat(y); 
      return ((x < y) ? -1 : ((x > y) ? 1 : 0)); 
     }; 

     jQuery.fn.dataTableExt.oSort['numeric-comma-desc'] = function(a,b) { 
      var x = (a == "-") ? 0 : a.replace(",",""); 
      var y = (b == "-") ? 0 : b.replace(",",""); 
      x = parseFloat(x); 
      y = parseFloat(y); 
      return ((x < y) ? 1 : ((x > y) ? -1 : 0)); 
     }; 


     $(document).ready(function() { 
      $('#example').dataTable({ 
       "sPaginationType": "full_numbers", 
       "bPaginate": false, 
       "aoColumns": [ 
           null, 
           null, 
           null, 
           { "sType": "numeric-comma" }, 
           null 
       ] 
      }); 

     }); 
    </script> 
관련 문제