Cloning a row, editing it then adding it.
Cloning a row, editing it then adding it.
I'm trying to clone an existing row, change a few of the column values, then append the cloned row back to the table with a redraw of the table to apply sorting and formatting and things. I've got it working using the fnAddTr plugin, but I'm doing it by converting the row to .html. Is there a way to add it without having to convert it to HTML? Here is a snippet of the code I'm working with:
[code]
var row_clone = $('#claimTable tbody tr:eq(1)').clone();
row_clone.find('input[name="claim_id[]"]').each(function(){
$(this).val(v);
});
row_clone.find('input[name="claim_id_row[]"]').each(function(){
$(this).val(v);
});
row_clone.find('input[name="serial_num[]"]').each(function(){
$(this).attr('value', k);
});
row_clone.find('input[name="ship_date[]"]').each(function(){
$(this).attr('id', 'dp' + v);
});
var row_copy = '' + row_clone.html() + '';
oTable.fnAddTr($(row_copy)[0]);
[/code]
I tried just passing row_clone, instead of $(row_copy)[0], but it didn't seem to work.
[code]
var row_clone = $('#claimTable tbody tr:eq(1)').clone();
row_clone.find('input[name="claim_id[]"]').each(function(){
$(this).val(v);
});
row_clone.find('input[name="claim_id_row[]"]').each(function(){
$(this).val(v);
});
row_clone.find('input[name="serial_num[]"]').each(function(){
$(this).attr('value', k);
});
row_clone.find('input[name="ship_date[]"]').each(function(){
$(this).attr('id', 'dp' + v);
});
var row_copy = '' + row_clone.html() + '';
oTable.fnAddTr($(row_copy)[0]);
[/code]
I tried just passing row_clone, instead of $(row_copy)[0], but it didn't seem to work.
This discussion has been closed.
Replies
Allan
Allan