I am working in a website in which page is displaying data in table when some option is selected. The page is creating and displaying data in a table dynamically by converting the json output from AJAX call to html table output. I need to sort individual columns of the table according to alphabetically/date wise/open-close when subsequent table header is clicked.
my code is something like this:-
if (json.d[0].length > 0){
htmlTable += "<table class='table table-striped' id='myTable'>"+
"<tr>"+
"<th style='background-color: #df820a;'>Customer</button></th>"+
"<th style='background-color: #df820a;'>Survey date</th>"+
"<th style='background-color: #df820a;'>Contact by</th>"+
"<th style='background-color: #df820a;'>Assigned to</th>"+
"<th style='background-color: #df820a;'>Status</th>"+
"<th style='background-color: #df820a;'>Resolution</th>"+
"<th style='background-color: #df820a;'>Coupon offered</th>"+
"</tr>";
for (var i = 0; i < json.d[0].length; i++) {
htmlTable += "<tr>"+
"<td>" + json.d[0][i].customerName1 + "</td>"+
"<td>" + json.d[0][i].createdDt1 + "</td>"+
"<td>" + json.d[0][i].customerContactBy1 + "</td>"+
"<td>" + json.d[0][i].AssignedTo1 + "</td>"+
"<td>" + json.d[0][i].alertStatus1 + "</td>"+
"<td>" + json.d[0][i].resolution1 + "</td>"+
"<td>" + json.d[0][i].couponOffered1 + "</td>"+;
"</tr>";
}
htmlTable += "</table>";
$('#AlertManagement').html(htmlTable);
}
Is there any way by which I can sort these dynamically generated columns???