如何使用jquery.datatable
和jeditable
插件没有url。我只是想编辑功能,而不需要保存到服务器。这是我尝试过的:
$('td', oTable.fnGetNodes()).editable(function(value, settings) {
console.log(this);
console.log(value);
console.log(settings);
return(value);}, {
type : 'textarea',
submit : 'OK',
callback: function( sValue, y ) {
var aPos = oTable.fnGetPosition( this );
oTable.fnUpdate( sValue, aPos[0], aPos[1] );
},
});
我采用了datatable .net上的Jeditable(或Jeditable)示例,并根据Golden Bird在问题中提供的内容和Jeditable文档对该主题的说明对其进行了修改。为了测试,您可以编辑网格中的任何值,排序立即应用,其他与数据相关的一切也可以工作(例如搜索新值)。
-
使用(隐式)
"type" : "textarea"
的示例 -
例子使用
"type" : "select"
$(document).ready(function() {
var oTable = $('table').dataTable();
var theCallback = function(v, s) {
// Do something with the new value
return v;
};
$(oTable).find('td').editable(theCallback, {
"callback": function(sValue, y) {
var aPos = oTable.fnGetPosition(this);
oTable.fnUpdate(sValue, aPos[0], aPos[1]);
},
"data": "{'0':'0%', '.1':'10%', '.15': '15%', '.2': '20%', 'selected':'0'}",
"type" : "select",
"submit" : "OK",
"style": {"height": "100%","width": "100%"}
});
});