2013-01-07 1 views
3

우리는 HandsonTable을 사용하여 테이블과 같은 Excel을 작성하려고합니다. 어떤 이유로 setDataAtCell 메서드가 작동하지 않는 것 같습니다. 디버깅하는 동안이 메서드에 의해 데이터가 제대로 설정되어 있지만 테이블을 표시하는 동안 업데이트 된 값이 표시되지 않습니다. 나는 정말로 무언가를하고 있을지도 모른다. 당신의 도움은 깊이 appreicated. wiki에서HandonTable setDataAtCell이 작동하지 않습니다.

  container.handsontable({ 
       data: getChemicalData(), 
       minRows: 5, 
       minCols: 6, 
       minSpareRows: 2, 
       minSpareCols: 0, 
       colHeaders: ["<b>TUBE</b>", "<b>A</b>", "<b>B</b>", "<b>C</b>", "<b>D</b>", "<b>Total in Item, grams</b>"], 
       colWidths: [200,50,50,50,50,100], 
       columns: [ 
        { 
         data: "Effect", 
         type: {editor: Handsontable.AutocompleteEditor }, 
         source: ["RD", "SB", "WG"], 
         strict: true 

        }, 
        { 
         data: "A" 
        }, 
        { 
         data: "B" 
        }, 
        { 
         data: "C" 
        }, 
        { 
         data: "D" 
        }, 
        { 
         data: "TotalInGms", 
         readOnly: true 
        } 

       ], 

      cells: function (row, col, prop) 
      {  
       var cellProperties = {}; 
       if ((row === 0 && col === 0) || (row === 1)) 
       { 
        cellProperties.readOnly = true; 
       } 
       return cellProperties; 
      }, 
      onBeforeChange: function (data) { 


       if (data[0][1] !== "Effect") { 

        if (parseInt(data[0][3]) > 0) { 

        } 
        else { 
         return false; 
        } 
       } 

      }, 
       onChange: function (data, source) { 
       if (source === 'loadData') { 
        return; //don't show this change in console 
       } 

       if (isBypass === true) { 
        return; 
       } 
       var sel = $("#example").handsontable('getSelected'); 
       if (sel != null) { 
        if (sel[0] === 0) { 
         var noOfRows = $("#example").handsontable('countRows'); 
         var totalGmsPerItem = 0; 
         var gmsPerTube = 0; 
         for (var i = 2; i < noOfRows; i++) { 
          gmsPerTube = parseInt($("#example").handsontable('getDataAtCell', i, sel[1])); 
          if (gmsPerTube > 0) { 
           totalGmsPerItem = parseInt(totalGmsPerItem) + gmsPerTube * parseInt(data[0][3]); 
          } 
         } 
         var noOfCols = $("#example").handsontable('countCols'); 

         isBypass = true; 
         $("#example").handsontable('setDataAtCell', 3, 2, totalGmsPerItem); 
         //$("#example").handsontable('setDataAtCell', sel[0],sel[1], 19); 
         isBypass = false; 

        } 
       } 

       return; 

      } 


      }); 

답변

0

: 셀에

handsontable('setDataAtCell', row, col, value)

설정 새로운 가치 다음은 코드입니다. 한 번에 많은 셀을 변경하려면 [[row, col, value], ...] 형식의 배열을 유일한 매개 변수로 전달하십시오. 골은 어떤 방법 setDataAtRowProp이없는 내가 그랬던 것처럼 당신은 깨진 버전을 다운로드해야합니다

볼 열 (열 재정렬 된 경우, 현재의 순서가 사용됩니다주의)의 인덱스와 setDataAtCell는 그 매개 변수를 방법.