当我将数据解析为handontable时,我点击按钮。我想要替换“A”列中的所有行。更改后,“A”列中的每一行看起来像(101,102,103),将数据保存在其他列中。有人可以帮帮我吗?谢谢。
$(document).ready(function () {
var data = [
["2008", 10, 11, 12, 13],
["2009", 20, 11, 14, 13],
["2010", 30, 15, 12, 13]
];
var $container = $("#example1");
$container.handsontable({
data: data,
startRows: 5,
startCols: 5,
colHeaders: true,
minSpareRows: 1
});
});
</style><!-- Ugly Hack due to jsFiddle issue: http://goo.gl/BUfGZ -->
<script src="http://handsontable.com/lib/jquery.min.js"></script>
<script src="http://handsontable.com/dist/jquery.handsontable.full.js"></script>
<link rel="stylesheet" media="screen" href="http://handsontable.com/dist/jquery.handsontable.full.css">
<link rel="stylesheet" media="screen" href="http://handsontable.com/demo/css/samples.css?20140331">
<style type="text/css">
body {background: white; margin: 20px;}
h2 {margin: 20px 0;}
<div class="handsontable" id="example1"></div>
<p>
<button name="dump" data-dump="#example1" title="Prints current data source to Firebug/Chrome Dev Tools">Dump
data to console
</button>
</p>
答案 0 :(得分:1)
添加以下代码:
var newData=[101,102,103];//your data
$.each(newData,function(i,v){
$('#example1').handsontable('setDataAtCell', i, 0, v);
})