How to make dynamic Header with Html table and Json using asp .net
How to make dynamic Header with Html table and Json using asp .net
khan_k_sameer
Posts: 2Questions: 2Answers: 0
I have Tried .....
HTML Page Code is
<table id="tbDetails" class="display; cell-border">
<thead></thead>
<tbody></tbody>
</table>
Jquery Code is .....
$.ajax({
url: "testing.asmx/Customize_Datatable",
type: "POST",
dataType: "json",
crossDomain: true,
success: function (data) {
$('#tbDetails').dataTable({
data: data,
"bInfo": false, //Dont display info e.g. "Showing 1 to 4 of 4 entries"
"paging": false,//Dont want paging
"bPaginate": false,//Dont want paging
"bFilter": false, //hide Search bar
"bSort": false,
"orderCellsTop": true,
});
},
error: function (jqXHR, textStatus, errorThrown) {
alert('error: ' + textStatus + ': ' + errorThrown);
}
});
And Webservice Code is
[WebMethod]
[ScriptMethod(UseHttpGet = false, ResponseFormat = ResponseFormat.Json)]
public void Customize_Datatable()
{
try
{
String Query = "<table id = 'tbDetails' class='display' style='width:100%'> " +
" <thead> " +
" <tr> " +
" <th> Name </th> " +
" <th> Position </th> " +
"<th> Office </th> " +
"<th> Age </th> " +
"<th> Start date </th> " +
" <th> Salary </th> " +
" </tr> " +
" </thead>" +
"<tbody> " +
"<tr> " +
"<td> Tiger Nixon </td> " +
"<td> System Architect </td> " +
"<td> Edinburgh </td> " +
"<td> 61 </td> " +
"<td> 2011 / 04 / 25 </td> " +
"<td>$320,800 </td> " +
"</tr> " +
" </tbody> " +
"</table> ";
// return Query;
JavaScriptSerializer js = new JavaScriptSerializer();
Context.Response.Write(js.Serialize(Query));
}
catch (Exception ex)
{
throw ex;
}
}
Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.
This discussion has been closed.
Answers
I don't understand the question. What do you mean by "dynamic Header"?
Please use Markdown formatting when posting code.
https://datatables.net/manual/tech-notes/8