gpt4 book ai didi

javascript - 如何替换handsontable中一列中的所有内容?

转载 作者:太空宇宙 更新时间:2023-11-04 12:42:20 24 4
gpt4 key购买 nike

当我将数据解析为 handsontable 并单击按钮时。我想替换“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>

最佳答案

添加这段代码:

  var newData=[101,102,103];//your data

$.each(newData,function(i,v){
$('#example1').handsontable('setDataAtCell', i, 0, v);
})

关于javascript - 如何替换handsontable中一列中的所有内容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26774064/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com