I am trying to implement a functionality in my view where the table expands into a detail row. Although the expand function is working and fetching the data successfully, I am facing an issue where the detail table that I intend to display is not appearing. Here is a snippet of the HTML code in the view:
<table>
<thead>
<tr><td>Column 1</td></tr>
<tr><td>Column 2</td></tr>
<tr><td>Column 3</td></tr>
</thead>
<tbody>
foreach(var data in ViewData["data"] as List<DataModel>)
{
<tr>
<td>@data.Data1</td>
<td>@data.Data2</td>
<td>@data.Data3</td>
</tr>
<tr>
<td class="hiddenRow" colspan="6">
<div class="accordion-body collapse" id="@data.MembershipId">
<div id="<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="7520051114011025141b10192a35111401145b381018171007061d1c053c11">[email protected]</a>" class="container">
</div>
</div>
</td>
</tr>
}
</tbody>
</table>
Furthermore, I have implemented JQuery to use @data.MembershipId for retrieving the data for the detail table:
$(document).ready(function () {
var memberId;
$('.header').click(function () {
$(this).nextUntil('tr.header').slideToggle(50);
memberId = $(this).data("target").replace("#", "");
$.ajax({
type: "GET",
url: "GetActivity",
data: { membershipId: memberId },
success: OnSuccess,
error: OnError
});
});
function OnSuccess(data) {
var TableContent = "<table>" +
"<thead>" +
"<tr>" +
"<td>Detail Column 1</td>" +
"<td>Detail Column 2</td>" +
"<td>Detail Column 3</td>" +
"<td>Detail Column 4</td>" +
"<td>Detail Column 5</td>" +
"</tr>" +
"</thead>" +
"<tbody>";
for (var i = 0; i < data.length; i++) {
TableContent += "<tr>" +
"<td>" + data[i].data1 + "</td>" +
"<td>" + data[i].data2 + "</td>" +
"<td>" + data[i].data3 + "</td>" +
"<td>" + data[i].data4 + "</td>" +
"<td>" + data[i].data5 + "</td>" +
"</tr>";
}
TableContent += "</tbody></table>";
$("#UpdatePanel_" + memberId).html(TableContent);
}
function OnError(data) {
alert("Error: " + data)
}
});
Although the AJAX call to the Controller to fetch SQL data and retrieve the Data Model List seems to be functioning correctly, and the table is being built with the data upon inspection, it fails to display anything when expanding the table row.
I suspect this issue might not be related to the CSS, but I could be mistaken.