Data from Ajax, Edit in Place
Data from Ajax, Edit in Place
The code I have currently grabs a result set and build the table dynamically. However, I cannot figure out how to get jeditable to work with the dynamically created table. I have viewed the examples, and they are all for data that is already in the table. Thanks for any information!
This discussion has been closed.
Replies
Thanks for any help. If I figure this out, I will post what I did.
The issue is that the DOM is created after the table has been created, therefore you need to add the events after that event. These links might be useful for you:
http://datatables.net/examples/example_events_pre_init.html
http://datatables.net/examples/example_events_post_init.html
http://datatables.net/forums/comments.php?DiscussionID=159
http://sprymedia.co.uk/article/Visual+Event - lets you see what elements have events applied to them.
Regards,
Allan
[code]
oTable = $('#displayData').dataTable(
{
"sDom" : '<"top"flip>rt<"bottom"<"clear">',
"bAutoWidth" : false,
"bProcessing" : true,
"fnRowCallback" : function (nRow, aData, iDisplayIndex) {
$(nRow).attr('id', 'row_' + aData[0]);
for (i = 0; i < aData.length; i ++) {
$('td:eq(' + i + ')', nRow).editable('/async/edit/', {
'callback': function (sValue, y) {
var aPos = oTable.fnGetPosition(this);
oTable.fnUpdate(sValue, aPos[0], aPos[1]);
},
'height': '14px'
});
}
return nRow;
},
"sAjaxSource" :
'<?= $this->baseUrl(); ?>/async/fetchall/type/' + type + '/db/' + db
}
);
[/code]
* Edited by Allan to add code highlighting.