change css of filtered rows in datatable
change css of filtered rows in datatable
i am using $.fn.afnFiltering.push(...) to filter rows in my table based on a certain daterange....i cannot figure out how to address individual rows inside this function....
heres my code...
[code]$.fn.dataTableExt.afnFiltering.push(
function (oSettings, aData, iDataIndex) {
var iFini = document.getElementById('dateStart').value;
var iFfin = document.getElementById('dateEnd').value;
if (iFini == "" && iFfin == "") {
return true;
}
else if (iFini != "" && iFfin == "") {
return true;
}
else if (iFini == "" && iFfin != "") {
return true;
}
else if (iFini != "" && iFfin != "") {
var sdate = new Date();
var edate = new Date();
var initialdt = iFini.split("/");
var enddt = iFfin.split("/");
var filterdt1 = aData[3].split(" ");
var filterdt = filterdt1[0].split("/");
var msg = "";
if ((Number.parseInvariant(filterdt[0]) + 1 >= Number.parseInvariant(initialdt[0]) + 1 && Number.parseInvariant(filterdt[0]) + 1 <= Number.parseInvariant(enddt[0]) + 1) && (Number.parseInvariant(filterdt[1]) >= Number.parseInvariant(initialdt[1]) && Number.parseInvariant(filterdt[1]) <= Number.parseInvariant(enddt[1])) && (Number.parseInvariant(filterdt[2]) >= Number.parseInvariant(initialdt[2]) && Number.parseInvariant(filterdt[2]) <= Number.parseInvariant(enddt[2]))) {
// msg = "initialdt: " + initialdt[0] + "/" + initialdt[1] + "/" + initialdt[2] + "====" + "enddt: " + enddt[0] + "/" + enddt[1] + "/" + enddt[2] + "====Filter:" + filterdt[0] + "/" + filterdt[1] + "/" + filterdt[2] + "/n"
//$(this).push();
return true;
}
}
return true;
}
);[/code]
thanks
heres my code...
[code]$.fn.dataTableExt.afnFiltering.push(
function (oSettings, aData, iDataIndex) {
var iFini = document.getElementById('dateStart').value;
var iFfin = document.getElementById('dateEnd').value;
if (iFini == "" && iFfin == "") {
return true;
}
else if (iFini != "" && iFfin == "") {
return true;
}
else if (iFini == "" && iFfin != "") {
return true;
}
else if (iFini != "" && iFfin != "") {
var sdate = new Date();
var edate = new Date();
var initialdt = iFini.split("/");
var enddt = iFfin.split("/");
var filterdt1 = aData[3].split(" ");
var filterdt = filterdt1[0].split("/");
var msg = "";
if ((Number.parseInvariant(filterdt[0]) + 1 >= Number.parseInvariant(initialdt[0]) + 1 && Number.parseInvariant(filterdt[0]) + 1 <= Number.parseInvariant(enddt[0]) + 1) && (Number.parseInvariant(filterdt[1]) >= Number.parseInvariant(initialdt[1]) && Number.parseInvariant(filterdt[1]) <= Number.parseInvariant(enddt[1])) && (Number.parseInvariant(filterdt[2]) >= Number.parseInvariant(initialdt[2]) && Number.parseInvariant(filterdt[2]) <= Number.parseInvariant(enddt[2]))) {
// msg = "initialdt: " + initialdt[0] + "/" + initialdt[1] + "/" + initialdt[2] + "====" + "enddt: " + enddt[0] + "/" + enddt[1] + "/" + enddt[2] + "====Filter:" + filterdt[0] + "/" + filterdt[1] + "/" + filterdt[2] + "/n"
//$(this).push();
return true;
}
}
return true;
}
);[/code]
thanks
This discussion has been closed.
Replies
It's a nice idea highlighting the rows which match your search - I like that :-). So I guess you want the TR element? For that what you can do is: oSettings.aoData[ iDataIndex ].nTr . It's an internal reference to the row, so you can add / remove a class as needed.
Allan
is there something i am missing????
thanks for the help...
Allan
is there any way i can call fnDraw() when the next or one of the paging buttons is clicked such that it updates that page and runs my filter alongwith it....
Allan
i am using fnGetNodes() to get all the nodes in the datatable....and then iterating over each row and adding a class to it but still no luck...only the rows in the current view get updated...why is that happening...
thanks
Allan
this is not public yet so i wont be able to connect you with the site....in the meantime heres another problem...if my data table has a significant amount of rows...afnfiltering.push causes a too much recursion error on the client....any way to get around this...
Allan
Allan
i am using bvisible=false for some columns but need to still get the values from the columns for a db call....how do i get those values from the hidden columns....currently i am getting nulls....
this is how i am trying to get the values
var CaseChapter = $(this).find("td:nth-child(5)").text();
var CaseLink = $(this).find("td:nth-child(6)").text();
case link is hidden and doesnt get a value...while chapter is visible and gets the value...
thanks
Allan