[英]need help with editable tables in jQuery ( DataTables plugin )
I'm trying to use jQuery and its plugin DataTables ( http://www.datatables.net/release-datatables/examples/api/editable.html ), to make an editable table.我正在尝试使用 jQuery 及其插件 DataTables ( http://www.datatables.net/release-datatables/examples/api/editable.ZFC35FDC70D5FC69D269883A822C7A.EZ可编辑表)
Here's my code so far.到目前为止,这是我的代码。 The top part of it works great by generating a table inside a DIV with the data from a js array.通过在 DIV 中使用 js 数组中的数据生成一个表,它的顶部效果很好。
Yet I also need this table to be editable.然而,我还需要这个表是可编辑的。 I have found an example code for it ( see bottom part ) but kinda can't figure out how to apply it to my table?我找到了它的示例代码(见底部),但有点不知道如何将它应用到我的表中?
Any ideas?有任何想法吗? Thanks!谢谢!
$(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...
I've used this plugin http://square-bracket.com/openjs我用过这个插件http://square-bracket.com/openjs
The example I see states to initialize your table like:我看到的示例状态初始化您的表,如:
$('#example').dataTable(options).makeEditable(options);
That being said, I haven't gotten it to work yet either.话虽如此,我还没有让它工作。
This is an example that works for me:这是一个对我有用的例子:
$('#tblDataTable2').dataTable({
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"aaSorting": [[ 0, "asc" ]],
"aoColumnDefs": [
{ "sClass": "center", "aTargets": [ 0, 1 ] }
]
}).makeEditable({
sAddURL: "Setting?operation=create",
sUpdateURL: "Setting?operation=update",
"aoColumns": [
{ placeholder: '' },
{ placeholder: '' }
],
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.