Monday, 18 April 2016
How to use Search, Copy, Print, Excel files and Pdf options Jquery Datatable in .NET
var oTable;
/* Add the events etc before DataTables hides a column */
$(".tableclassname thead input").keyup(function () {
/* Filter on the column (the index) of this element */
oTable.fnFilter(this.value, oTable.oApi._fnVisibleToColumnIndex(
oTable.fnSettings(), $(".csClientWithotLogTable thead input").index(this)));
});
/*
* Support functions to provide a little bit of 'user friendlyness' to the textboxes
*/
$(".tableclassname thead input").each(function (i) {
this.initVal = this.value;
});
$(".tableclassname thead input").focus(function () {
if (this.className == "search_init1") {
this.className = "";
this.value = "";
}
});
$(".tableclassname thead input").blur(function (i) {
if (this.value == "") {
this.className = "search_init1";
this.value = this.initVal;
}
});
oTable = $('#tableidname ').dataTable().fnDestroy();
var tt = new $.fn.dataTable.TableTools(oTable, {
"dom": '<"pad5"CT><"clear"><lf<"clear">r<t>ip>',
"sSwfPath": "/FolderName/Flash/copy_csv_xls_pdf.swf", //path of the flash file
"aButtons": [
{
"sExtends": "copy",
"mColumns": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
"oSelectorOpts": { filter: 'applied', order: 'current' },
},
{
"sExtends": "csv",
"mColumns": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
"oSelectorOpts": { filter: 'applied', order: 'current' },
},
{
"sExtends": "xls",
"mColumns": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
"oSelectorOpts": { filter: 'applied', order: 'current' },
},
{
"sExtends": "pdf",
"sPdfOrientation": "landscape",
"sPdfMessage": "Report",
"mColumns": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
"oSelectorOpts": { filter: 'applied', order: 'current' },
},
{
"sExtends": "print",
"mColumns": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
"oSelectorOpts": { filter: 'applied', order: 'current' },
},
]
});
/* Add the events etc before DataTables hides a column */
$(".tableclassname thead input").keyup(function () {
/* Filter on the column (the index) of this element */
oTable.fnFilter(this.value, oTable.oApi._fnVisibleToColumnIndex(
oTable.fnSettings(), $(".csClientWithotLogTable thead input").index(this)));
});
/*
* Support functions to provide a little bit of 'user friendlyness' to the textboxes
*/
$(".tableclassname thead input").each(function (i) {
this.initVal = this.value;
});
$(".tableclassname thead input").focus(function () {
if (this.className == "search_init1") {
this.className = "";
this.value = "";
}
});
$(".tableclassname thead input").blur(function (i) {
if (this.value == "") {
this.className = "search_init1";
this.value = this.initVal;
}
});
oTable = $('#tableidname ').dataTable().fnDestroy();
var tt = new $.fn.dataTable.TableTools(oTable, {
"dom": '<"pad5"CT><"clear"><lf<"clear">r<t>ip>',
"sSwfPath": "/FolderName/Flash/copy_csv_xls_pdf.swf", //path of the flash file
"aButtons": [
{
"sExtends": "copy",
"mColumns": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
"oSelectorOpts": { filter: 'applied', order: 'current' },
},
{
"sExtends": "csv",
"mColumns": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
"oSelectorOpts": { filter: 'applied', order: 'current' },
},
{
"sExtends": "xls",
"mColumns": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
"oSelectorOpts": { filter: 'applied', order: 'current' },
},
{
"sExtends": "pdf",
"sPdfOrientation": "landscape",
"sPdfMessage": "Report",
"mColumns": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
"oSelectorOpts": { filter: 'applied', order: 'current' },
},
{
"sExtends": "print",
"mColumns": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
"oSelectorOpts": { filter: 'applied', order: 'current' },
},
]
});
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment