将handsontable中所做的更改绑定到handsontable中同一行中的另一个值
Tying changes made in handsontable to another value in the same row in handsontable
我正在使用handsontable来方便地通过web浏览器更改大型表。问题是需要将更改绑定到唯一ID,例如RDBMS中的主ID。对于问题/示例/代码中的数据,custId与主键或唯一标识符一样好。
如何将数组changes:中的changes:值与custId..联系起来?
看起来我试图在hot5上调用一个函数,即使hot5正在渲染。[看起来不太可能,可能是根本原因]这就是为什么getchangedPin2返回null,这给我带来了问题的第二部分,是否有不同的方式来实现这一点…?
$(document).ready(function () {
container = document.getElementById('example');
hot5 = new Handsontable(container, {
data: request,
dataSchema: {custID: null, areaCode: null, pinNo: null, importantStatus: null, subAreaCode: null},
colHeaders: ['custID', 'areaCode', 'pinNo', 'importantStatus', 'subAreaCode'],
columns: [
{ data: 'custID'},
{ data: 'areaCode'},
{ data: 'pinNo'},
{ data: 'importantStatus'},
{ data: 'subAreaCode'}
],
afterChange: function (changes, source) {
if (source=== 'loadData') {
return;
}
showValInConsole(changes);
console.log("the changes "+ getchangedpinNo2(changes[0],'custID'));
},
columnSorting: true,
minSpareRows: 1
});
var showValInConsole = function(changes){
var rowIndex = changes[0];
var col = changes[1];
var oldCellValue = changes[2];
var newCellValue = changes[3];
var row_ref = getchangedPin2(changes[0],'custID');
console.log(rowIndex + " " + col + " "+ oldCellValue + " "+ newCellValue + " " +getchangedPin2(rowIndex,'custID') );
};
var getchangedPin2 = function(row, col){
var urnChanged2 = hot5.getDataAtRowProp(row, col);
return urnChanged2;
};
});
<link href="http://handsontable.com//bower_components/handsontable/dist/handsontable.full.min.css" rel="stylesheet"/>
<script src="http://handsontable.com//bower_components/handsontable/dist/handsontable.full.min.js"></script>
<!DOCTYPE html>
<html>
<head>
<title>Test1</title>
<meta charset="ISO-8859-1">
<script src="js/handsontable.full.js"></script>
<script type="text/javascript" src="js/test.js"></script>
<script src="js/jquery-1.11.3.min.js"></script>
<link rel="stylesheet" media="screen" href="css/handsontable.full.css">
</head>
<body>
<div id="hoTable"></div>
<input id="SubmitButton" type="button" value="Submit" />
</body>
</html>
注意:无法添加handsontable.full.min.css和handsontable.full.js
这个问题的答案可以解释你的情况。总之,您可以阅读这里的文档来理解Handsontable使用的排序插件。它利用了所谓的logicalIndex
,因为data
数组永远不会突变;相反,它们保留了第二个引用physicalIndex
-es的数据结构。
这一切都归结为以下一行代码:
physicalIndex = instance.sortIndex[logicalIndex][0];
其中instance
应该是Handson实例,logicalIndex
应该是changes[0][0]
。
相关文章:
- Windows8应用程序(html&Javascript):从图片库(除了文件选择器)显示图像的另一种方式
- 如何设置默认<ui视图>在另一<ui视图>
- 使用Javascript,如何显示<tr>在另一<tr>悬停时,隐藏第二个<tr>
- 当点击另一件事时,将焦点设置为一件事
- Javascript/AngularJs-如何用另一个数组中的对象填充数组
- 数组值的排序以匹配另一个数组ES6
- 选择随机数组元素并放置到另一个数组中
- 根据另一个数组对数组进行排序,包括位置和字符串[ES6]
- jQuery:使用substr()的另一种方法
- 将“潜水高度”设置为“另一潜水高度”
- 我正在创建一个聊天,但每次我发送消息时,它都不会让我再发送另一条消息,就像表格一样;不起作用
- 从一个数组中移除字符串(如果存在于另一个数组)
- JS迭代一个数组,同时更改另一个数组
- 可以't获取setInterval函数以使用javascript中的this.function_name调用另一
- 查找数组's按属性不存在于另一个数组中的对象
- 另一种显示和隐藏按钮的方式
- 传递表单值并移动到另一页
- 如何使一个Math.random数组元素比另一个数组元素更有可能被选中
- 如何获取数组详细信息另一页
- 单击()的另一种方式