使用Jquery datatable jeditable而不使用必填字段URL

你怎么能使用jquery.datatable和没有url的jeditable插件。 我只想要编辑function而不保存到服务器。 这就是我尝试过的:

 $('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] ); }, }); 

我在datatables.net上采用了Jeditable(或jEditable)示例,并根据问题中提供的Golden Bird以及Jeditable文档对此主题的说法对其进行了修改。 要进行测试,您可以编辑网格中的任何值,排序立即应用,其他所有与数据表相关的工作也可以(例如,搜索新值)。

  • 使用(隐式) "type" : "textarea"示例"type" : "textarea"

  • 使用"type" : "select"示例"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%"} }); });