我试图用jQuery和它的插件DataTables(http://www.datatables.net/release-datatables/examples/api/editable.html)来创建一个可编辑的表格。需要在jQuery(DataTables插件)中编辑表格的帮助
这是我的代码到目前为止。它的顶部部分通过在一个DIV中使用js数组中的数据生成一个表。
但我还需要这张表是可编辑的。我找到了一个示例代码(见底部),但有点不知道如何将它应用到我的表中?
任何想法?谢谢!
$(document).ready(function() {
$('#dynamic').html('<table cellpadding="0" cellspacing="0" border="0" class="display" id="example"></table>');
/// create a table within the '#dynamic' DIV
$('#example').dataTable({
"aaData": numbarr, /////// takes data from the 'numbarr' js array.
"aoColumns": [
{ "sTitle": "Country " }, //// column names
{ "sTitle": "Number " },
{ "sTitle": "Tariff ID " },
{ "sTitle": "Customer Acc " },
{ "sTitle": "Customer Name " },
{ "sTitle": "Payment Terms " },
{ "sTitle": "Payout/Call " },
{ "sTitle": "Payout/Min " },
]
});
///////////////////////////// the code above workd fine!
////////////////// this code was taken from an example, not sure how to connect it with my table...
$('td', oTable.fnGetNodes()).editable('../examples_support/editable_ajax.php', {
"callback": function(sValue, y) {
var aPos = oTable.fnGetPosition(this);
oTable.fnUpdate(sValue, aPos[0], aPos[1]);
},
"submitdata": function (value, settings) {
return {
"row_id": this.parentNode.getAttribute('id'),
"column": oTable.fnGetPosition(this)[2]
};
},
"height": "12px"
});
////////////////// this code was taken from an example, not sure how to connect it with my table...