Jquery 从服务器获取数据时使用keytable的datatable js
当数据来自服务器时,无法使datakey js与datatable js一起工作 当数据是html时,但当移动以从服务器获取数据时,这是有效的 根本不起作用Jquery 从服务器获取数据时使用keytable的datatable js,jquery,datatables,Jquery,Datatables,当数据来自服务器时,无法使datakey js与datatable js一起工作 当数据是html时,但当移动以从服务器获取数据时,这是有效的 根本不起作用 var table = $('#' + attrs.id).dataTable({ "bProcessing": true, "bServerSide": false, "sAjaxDataProp": "data", "bDestroy": true, "aoColumns":
var table = $('#' + attrs.id).dataTable({
"bProcessing": true,
"bServerSide": false,
"sAjaxDataProp": "data",
"bDestroy": true,
"aoColumns": [
{ "mDataProp": ["a"] },
{ "mDataProp": ["b"] },
{ "mDataProp": ["c"] },
{ "mDataProp": ["d"] },
{ "mDataProp": ["e"] },
{ "mDataProp": ["f"] }
],
"sAjaxSource": '/api/phases',
});
var keys = new KeyTable({
"table": document.getElementById(attrs.id),
"initScroll": false
});
$('#' + attrs.id + ' tbody td').each(function () {
keys.event.action(this, function (nCell) {
/* Block KeyTable from performing any events while jEditable is in edit mode */
keys.block = true;
/* Initialise the Editable instance for this table */
$(nCell).editable(function (sVal, x) {
var aPos = table.fnGetPosition(this);
table.fnUpdate(sVal, aPos[0], aPos[1]);
keys.block = false;
return sVal;
}, {
"indicator": 'Saving...',
"tooltip": 'Click to edit...',
"onblur": 'submit',
"onreset": function () {
/* Unblock KeyTable, but only after this 'esc' key event has finished. Otherwise
* it will 'esc' KeyTable as well
*/
setTimeout(function () { keys.block = false; }, 0);
}
});
/* Dispatch click event to go into edit mode */
setTimeout(function () { $(nCell).click(); }, 0);
});
});
在单元格上按enter键时为什么不移动到编辑模式
有什么帮助吗?完成后只需集成keytable即可 这应该行得通
var table = $('#' + attrs.id).dataTable({
"bProcessing": true,
"bServerSide": false,
"sAjaxDataProp": "data",
"bDestroy": true,
"aoColumns": [
{ "mDataProp": ["a"] },
{ "mDataProp": ["b"] },
{ "mDataProp": ["c"] },
{ "mDataProp": ["d"] },
{ "mDataProp": ["e"] },
{ "mDataProp": ["f"] }
],
"sAjaxSource": '/api/phases',
"fnInitComplete": function () {
/* Apply a return key event to each cell in the table */
$('#' + attrs.id + ' tbody td').each(function () {
console.log(this);
keys.event.action(this, function (nCell) {
/* Block KeyTable from performing any events while jEditable is in edit mode */
keys.block = true;
/* Initialise the Editable instance for this table */
$(nCell).editable(function (sVal, x) {
var aPos = table.fnGetPosition(this);
table.fnUpdate(sVal, aPos[0], aPos[1]);
keys.block = false;
return sVal;
}, {
"indicator": 'Saving...',
"tooltip": 'Click to edit...',
"onblur": 'submit',
"onreset": function () {
/* Unblock KeyTable, but only after this 'esc' key event has finished. Otherwise
* it will 'esc' KeyTable as well
*/
setTimeout(function () { keys.block = false; }, 0);
}
});
/* Dispatch click event to go into edit mode */
setTimeout(function () { $(nCell).click(); }, 0);
});
});
}
});
var keys = new KeyTable({
"table": document.getElementById(attrs.id),
"initScroll": false
});