2016-10-03 111 views
0

我正在測試其中一個handontable的小提琴,並在移動列時發現問題。 請轉到下面的提琴並執行上述步驟。 http://jsfiddle.net/5u5vczcg/在Handsontable中移動列之後編輯單元格時數據不正確

var hot = new Handsontable(container, { 
    data: financeData, 
    colHeaders: ["Price", "Date", "1D Chg", "YTD Chg", "Vol BTC"], 
    rowHeaders: true, 
    stretchH: 'all', 
    sortIndicator: true, 
    columnSorting: true, 
    contextMenu: true, 
    manualColumnMove : true, 
    columns: [ 
    {type: 'numeric', format: '$0,0.00'}, 
    {type: 'date', dateFormat: 'DD/MM/YYYY', correctFormat: true}, 
    {type: 'numeric', format: '0.00%'}, 
    {type: 'numeric', format: '0.00%'}, 
    {type: 'numeric', format: '0.00'} 
    ] 
}); 

移動列到位價日期。 雙擊任何價格單元格,您將看到單元格中的值僅爲日期。 同樣,當你雙擊日期單元格時,它們也不會正確顯示數據。 請您檢查並解決。

回答

0

你在這方面面臨的問題應該是一個很老的fixed issue。經過多次測試/研究,如果我激活手動列移動選項,我確實對我的項目有同樣的行爲。

所以我的建議對你是選擇這兩個解決方案之一:

  1. 重新打開了他們的git的最新版本Handsontable的問題。
  2. 使用舊版本,我爲你所做的解決方法(0.15.0版本)

Your JS Fiddle uptaded

我認爲你可以開始和獲得的想法如何自定義您的Handsontable。對於你的情況,我所做的就是更新事件「afterColumnMove」兩個修改的列:

hot.addHook('afterColumnMove', function(sourceIndex, targetIndex) { 
    var 
    sourceValues = hot.getData(0,sourceIndex,hot.getData().length,sourceIndex), 
    sourceProperties =hot.getSettings().columns[sourceIndex], 
    sourceHeader=hot.getSettings().colHeaders[sourceIndex], 
    targetValues = hot.getData(0,targetIndex,hot.getData().length,targetIndex), 
    targetProperties =hot.getSettings().columns[targetIndex], 
    targetHeader=hot.getSettings().colHeaders[targetIndex], 

    newColumns=hot.getSettings().columns, 
    newHeaders=hot.getSettings().colHeaders; 

    newHeaders[sourceIndex]=targetHeader; 
    newHeaders[targetIndex]=sourceHeader; 
    newColumns[sourceIndex]=targetProperties; 
    newColumns[targetIndex]=sourceProperties; 

    hot.updateSettings({columns:newColumns,colHeaders:newHeaders}); 
    hot.populateFromArray(0,sourceIndex,sourceValues,hot.getData().length,sourceIndex); 
    hot.populateFromArray(0,targetIndex,targetValues,hot.getData().length,targetIndex); 
}); 

但是還有第三個選項:

  • 使用別的東西。根據您的預算,編輯版本的DataTables是恕我直言,你可以使用的最好的地方Handsontable,儘可能好看,當你試圖編輯你的數據&使用其他功能時,包含許多剩餘的錯誤。 (這個問題就是一個很好的例子)。
  • 相關問題