Handsontable을 처음 사용했습니다. 'getSelected'및 '변경'메서드 (remove_row)를 사용하여 선택한 여러 테이블 행을 삭제하려고합니다. 그러나 아래 코드를 사용하면 Firebug 및 "Uncaught TypeError : 정의되지 않은 속성 '0'을 Chrome에서 읽을 수 없다는 오류"선택 "이 발생합니다. 내가 선택한 행이나 얼마나 많은 행이든 상관 없습니다. 나는 여전히 오류가 발생하고 행이 삭제되지 않습니다. 나는 무엇을 잘못하고 있니?Handsontable 복수 행 삭제
$(document).ready(function() {
var myData = [
["", "Kia", "Nissan", "Toyota", "Honda"],
["2008", 10, 11, 12, 13],
["2009", 20, 11, 14, 13],
["2010", 30, 15, 12, 13]
];
$("#exampleGrid").handsontable({
data: myData,
startRows: 5,
startCols: 5,
//minSpareCols: 1, //always keep at least 1 spare row at the right
//minSpareRows: 1, //always keep at least 1 spare row at the bottom,
rowHeaders: true,
colHeaders: true,
contextMenu: true,
currentRowClassName: 'currentRow',
currentColClassName: 'currentCol'
});
$edit = $('#exampleGrid');
function editRows() {
$('#addtop').on('click', function() {
$edit.handsontable('alter', 'insert_row', 0);
});
$('#addbottom').on('click', function() {
$edit.handsontable('alter', 'insert_row');
});
var selection = $edit.handsontable('getSelected');
$('.deletebutton').on('click', function() {
$edit.handsontable('alter', 'remove_row', selection[0], selection[2]);
});
}
editRows();
});
여기 내 피들 http://jsfiddle.net/EfhqJ/48/입니다.
감사합니다.
해결되었습니다. $ ('. deletebutton'). on ('click', function() { var selection = $ edit.handsontable ('getSelected'); if (선택) { $ edit.handsontable ('alter', 'remove_row', 선택 [0], 선택 [2]); } }); – user2483128