hi i am trying to add export excel button to my table here is my code:
<script src="vendor/jquery/jquery.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/1.10.20/js/jquery.dataTables.min.js"></script>
<link href="https://cdn.datatables.net/1.10.20/css/jquery.dataTables.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" >
$(function () {
$.ajax({
type: "POST",
url: "daily.aspx/GetCustomers",
data: '{}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: OnSuccess,
failure: function (response) {
alert(response.d);
},
error: function (response) {
alert(response.d);
}
});
});
function OnSuccess(response) {
$("[id*=GridView2]").DataTable(
{
"sScrollX": "100%",
"bScrollCollapse": true,
scrollY: "100%",
bLengthChange: true,
lengthMenu: [[5, 10,20, -1], [5, 10,20, "All"]],
bFilter: true,
bSort: true,
bPaginate: true,
data: response.d,
columns: [{ 'data': 'sitecode' },
{ 'data': 'siteid' },
{ 'data': 'region' }]
});
};
</script>
What I have tried:
i tried to add
buttons: [
'copyHtml5',
'excelHtml5',
'csvHtml5',
'pdfHtml5'
]
in side the function
function OnSuccess(response) {
$("[id*=GridView2]").DataTable(
{
but it doesnt work