About how to append a code with datatable...
About how to append a code with datatable...
vinitsharma
Posts: 23Questions: 0Answers: 0
Hello everyone, I am using datatables and in my datatables, i have used the functionalities of Export Excel/PDF, Show/Hide Column and individual column search functionality. Previously for individual column search functionality, i simply appended one having elements within it to the datatable object. By appending this my individual search functionality did worked. But in this scenario, the problem i faced is that, while hiding any particular column using the Show/Hide button, my search textbox for that column wasnt getting hidden. So I got an idea of appending a whole new for individual search column as and when the header is called back(when column show/hide is used). But now having this idea, i am not able to have the individual search functionality. My code for individual column search is as under :
[code]
var TableHeader = $('#<%= gvwLineListing.ClientID %>' + ' thead');
if (TableHeader.dataTableSettings[0] != undefined) {
var TableHeaderTD = TableHeader.dataTableSettings[0].nTHead;
//$(TableHeaderTD).append(''); //Comment portion ends here. The work of appending is done in //another function.
$("thead input").keyup(function() {
oTable.fnFilter(this.value, oTable.oApi._fnVisibleToColumnIndex(
oTable.fnSettings(), $("thead input").index(this)));
});
$("thead input").each(function(i) {
this.initVal = this.value;
});
$("thead input").focus(function() {
if (this.className == "search_init") {
this.className = "";
this.value = "";
}
});
$("thead input").blur(function(i) {
if (this.value == "") {
this.className = "search_init";
this.value = this.initVal;
}
});
}
[/code]
In the above code, i was getting the individual column search feature when i wasn't appending the new on showing or hiding of any column. But now i want to append or attach this search functionality code each time the tableheader is called back. In short I want to have the individual search feature back, alongwith appending the new according to the columns being visible. So how can I attach that code alongwith the datatables or how can I associate this setting of individual column search in my datatables ? Please suggest me the way i can get my problem solved. Any suggestion is welcomed. Do i need to change the "this" keywords in the above code ? Please help me. Also the paging feature in my datatable isn't working well. Only the next/previous and first/last buttons are working, but when I click on any of the page numbers, I am simply getting an error in the datatables.js file. Please help. Thanx in advance.!
[code]
var TableHeader = $('#<%= gvwLineListing.ClientID %>' + ' thead');
if (TableHeader.dataTableSettings[0] != undefined) {
var TableHeaderTD = TableHeader.dataTableSettings[0].nTHead;
//$(TableHeaderTD).append(''); //Comment portion ends here. The work of appending is done in //another function.
$("thead input").keyup(function() {
oTable.fnFilter(this.value, oTable.oApi._fnVisibleToColumnIndex(
oTable.fnSettings(), $("thead input").index(this)));
});
$("thead input").each(function(i) {
this.initVal = this.value;
});
$("thead input").focus(function() {
if (this.className == "search_init") {
this.className = "";
this.value = "";
}
});
$("thead input").blur(function(i) {
if (this.value == "") {
this.className = "search_init";
this.value = this.initVal;
}
});
}
[/code]
In the above code, i was getting the individual column search feature when i wasn't appending the new on showing or hiding of any column. But now i want to append or attach this search functionality code each time the tableheader is called back. In short I want to have the individual search feature back, alongwith appending the new according to the columns being visible. So how can I attach that code alongwith the datatables or how can I associate this setting of individual column search in my datatables ? Please suggest me the way i can get my problem solved. Any suggestion is welcomed. Do i need to change the "this" keywords in the above code ? Please help me. Also the paging feature in my datatable isn't working well. Only the next/previous and first/last buttons are working, but when I click on any of the page numbers, I am simply getting an error in the datatables.js file. Please help. Thanx in advance.!
This discussion has been closed.
Replies