2014-09-16 5 views
0

데이터를 JSON 형식으로 수신하는 Handsontable 0.11.2 구현이 있습니다. 정렬 가능한 열을 만들었고 하나의 숫자 열 (숫자로 정의)을 가지고 문자열과 같은 정렬을 계속합니다. 나는 그것을 .0을 최종 서식에 추가하여 부동을 만들려고 시도했다. 0을 보여 주었지만 여전히 문자열로 정렬한다. Google 검색을 수행하는 몇 가지 잠재적 인 솔루션을 보았지만 제대로 작동하는 솔루션을 찾지 못했습니다. 내 handontable 설정은 아래에, 어떤 조언을 많이 주시면 감사하겠습니다.Handsontable 문자열과 같은 정수 정렬

$(document).on('click','.report',function(event) { 

$.ajax({ 
    type: "GET", 
    url: 'pending.php', 
    dataType: "json", 
    success: function(json) { 
     $('.item').remove(); 
     $(".welcome").hide(); 

     $(".carousel-inner").append("<div id='faTable'></div>"); 
     var $container = $("#faTable"); 
     var $parent = $container.parent(); 
     $container.handsontable({ 
      data: json.data, 
      startRows: 10, 
      startCols: 8, 
      rowHeaders: true, 
      manualColumnResize: true, 
      manualColumnMove: true, 
      columnSorting: true, 
      colHeaders: ['Lot','Number','Reason','Results','Billback','Status','Rank'], 
      contextMenu: true, 
      colWidths: [80,150,300,200,200,50,50], 
      columns: [ 
       {data: "lot", type: 'text',readOnly: true}, 
       {data: "number",type: 'text',readOnly: true}, 
       {data: "reason", type: 'text',readOnly: true}, 
       {data: "results", type: 'text',readOnly: true}, 
       {data: "billback", type: 'text',readOnly: true}, 
       {data: "status", type: 'text',readOnly: true}, 
       {data: "rank", type: 'numeric',readOnly: true} 
      ] 
     }); 
    }, 
    error: function(data) { 

    } 
}); 
}) 

답변

0

오픈 버그가 여기에 로그인있다 : https://github.com/handsontable/handsontable/issues/883

난 그냥 설정 handsontable의 데이터에 추가하기 전에이 같은 숫자 수 있습니다 모든 필터링 결국 :

var filterFloat = function (value) { 
    if(/^(\-|\+)?([0-9]+(\.[0-9]+)?|Infinity)$/ 
     .test(value)) 
     return Number(value); 
    return NaN; 
} 

// for the sake of sorting numbers vs strings: 
if(filterFloat(stringNumberVar)){ 
    stringNumberVar = filterFloat(stringNumberVar); 
} 

을 그것은 고정되어야하거나 당신이 포크에 꽤 쉽게 추가 할 수있는 무언가처럼 보입니다. 왜냐하면 그들은 날짜 변종도 약간 변덕 스럽기 때문입니다.

내가 그 일을 맡기로 결정하면 내가 돌아와서 알려줄거야.

0

PHP를 사용하여 MySQL을 쿼리하고 JSON 문자열로 변환하는 동안 0.15.0-beta2에서이 문제를 보았습니다. 나는 그 열에 대한 데이터가 또한 MySQL 질의로부터의 모든 데이터가 문자열로 반환되기 때문에 숫자로 형변환 될 필요가 있다는 것을 알았다. 다른 빈 문자열처럼 하단에 빈 문자열 및 종류 등의

$res = Zend_Registry::get('db')->fetchAll(' 
    SELECT * 
    FROM table 
'); 

foreach($res as &$s) { 
    $s['table_pk'] = (int) $s['table_pk']; 
    $s['position'] = ($s['position']!=0 ? (int) $s['position'] : null); 
    $s['height'] = ($s['height']!=0 ? (int) $s['height'] : null); 
    $s['count'] = ($s['count']!=0 ? (int) $s['count'] : null); 
} 

'널 (null)'표시 : 그래서 캐스팅 할 필요가 30 열, 넷 중 내가 SQL 결과이 루프를 썼다.