Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 82027

Move row from one table to another (and then select the new one with jQuery)

$
0
0
I've got two tables. I need to copy each row from one table, place it into the second table, delete the row from the first table, and then, change the name of a hidden input.

I've got the whole adding and removing rows working no problem (though it could probably be streamlined). Can anybody help with the last bit?
Also, feel free to make fun of me for doing something stupid (I have no idea what I'm doing).
$('#addAll').click(function() {
	accountTable = $('#accountUsersTable').dataTable();
	groupTable = $('#groupMembersTable').dataTable();
	
	accountTable.$('tbody tr').each(function() {
		var userData = accountTable.fnGetData(this);
		var newRowO = groupTable.fnAddData( [
			userData[0],
			userData[1],
			userData[2],
			userData[3]
		]);
		var newRow = groupTable.fnSettings().aoData[newRowO[0]].nTr;
		$('#groupMembersTable').find($(newRow)).children("input").attr("name", "addRow[]");
		accountTable.fnDeleteRow(this);
	});
});

Viewing all articles
Browse latest Browse all 82027

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>