How to pass table to row to form nested table through jQuery? -
i have records in datatable checkbox. trying append new table row on clicking checkbox. trying this.
here taking values row , formatting , displaying back. have complete different table want show.and i'm trying achieve checkbox.
$('#tblemployees').on('click', 'input[type="checkbox"].checkbox', function() { var tr = $(this).closest('tr'); var table = gettasks('here pass value table through ajax'); }); now, can display or hide when check or un-check checkbox.
table getting through ajax
function gettasks(id) { // creating inner table little styling var table = $('<table width="90%" style="margin: 0 auto;">'); // adding var titlerow = $('<tr>'); titlerow.append('<th> task # </th>'); titlerow.append('<th> task description </th>'); table.append(titlerow); $.ajax({ url: '@url.action("gettasks", "programs")', data: { id: id }, cache: false, type: "get", success: function (data) { $.each(data, function (key, value) { var row = $('<tr>'); row.append('<td>' + value.taskno + '</td>'); row.append('<td>' + value.taskdescription + '</td>'); table.append(row); }); } }); return table; }
function selectcolumn(rowid) { var tr = $('#tbcategory tbody tr[data-id=' + rowid + ']').after("<tr><td>hi, it's worked</td></tr>"); } when checkbox checked pass here table row id append table after tr. hope helps you.
Comments
Post a Comment