How to use DropDownLists for filtering
How to use DropDownLists for filtering
Newinthezone
Posts: 22Questions: 0Answers: 0
Hi
I was trying to use a dropdownlist for column filtering for one of my columns .Iam trying to use textboxes for 2 columns and drop down for the the 3rd. The textboxes are able to send a post back but not the drop down.
I add the dropdownlist in the tfoot and populate it with the unique values for that column.
But I am not able to get a postback when the value for the drop down box changes.
Please could you suggest what changes are required in the filtering function for data tables in this :
[code]
$(document).ready(function () {
var oTable = $('#example').dataTable({
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "/Employee/DataProviderAction",
"sPaginationType": "full_numbers"
});
$("tfoot input").keyup(function () {
/* Filter on the column (the index) of this element */
oTable.fnFilter(this.value, $("tfoot input").index(this));
});
/*
* Support functions to provide a little bit of 'user friendlyness' to the textboxes in
* the footer
*/
$("tfoot input").each(function (i) {
asInitVals[i] = this.value;
});
$("tfoot input").focus(function () {
if (this.className == "search_init") {
this.className = "";
this.value = "";
}
});
$("tfoot input").blur(function (i) {
if (this.value == "") {
this.className = "search_init";
this.value = asInitVals[$("tfoot input").index(this)];
}
});
$("tfoot input").change(function () {
/* Filter on the column (the index) of this element */
oTable.fnFilter(this.value, $("tfoot input").index(this));
});
});
[/code]
I tried changing keyup to change but i am sure something else must be required to.
I was trying to use a dropdownlist for column filtering for one of my columns .Iam trying to use textboxes for 2 columns and drop down for the the 3rd. The textboxes are able to send a post back but not the drop down.
I add the dropdownlist in the tfoot and populate it with the unique values for that column.
But I am not able to get a postback when the value for the drop down box changes.
Please could you suggest what changes are required in the filtering function for data tables in this :
[code]
$(document).ready(function () {
var oTable = $('#example').dataTable({
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "/Employee/DataProviderAction",
"sPaginationType": "full_numbers"
});
$("tfoot input").keyup(function () {
/* Filter on the column (the index) of this element */
oTable.fnFilter(this.value, $("tfoot input").index(this));
});
/*
* Support functions to provide a little bit of 'user friendlyness' to the textboxes in
* the footer
*/
$("tfoot input").each(function (i) {
asInitVals[i] = this.value;
});
$("tfoot input").focus(function () {
if (this.className == "search_init") {
this.className = "";
this.value = "";
}
});
$("tfoot input").blur(function (i) {
if (this.value == "") {
this.className = "search_init";
this.value = asInitVals[$("tfoot input").index(this)];
}
});
$("tfoot input").change(function () {
/* Filter on the column (the index) of this element */
oTable.fnFilter(this.value, $("tfoot input").index(this));
});
});
[/code]
I tried changing keyup to change but i am sure something else must be required to.
This discussion has been closed.