Filtering, refreshing table, and deleterow problems

Filtering, refreshing table, and deleterow problems

rksrks Posts: 5Questions: 0Answers: 0
edited May 2013 in General
So I'm not a pro with DataTables and I couldn't find out how to filter the results based on negative/positive values in the table. So I came around to deleting rows using fnDeleteRow but now I can't reset the table to the original values and I can't find any help. I've tried fnDraw(false), fnReloadAjax() (yes, I did load the plug-in), and fnDestroy() followed by reinit. Nothing works. All the below code does is delete the rows and when adding a new selection it maintains the previously deleted rows.

This is the code I'm using now:

[code]$(".debit-filter").change(function(){
if($(this).find("option:selected").val() == 1){
location.reload();
} else if($(this).find("option:selected").val() == 2){
oTable.fnReloadAjax();
$(".inv-amt").each(function(){
if(parseFloat($(this).text().replace("$", "").replace(",", "")) < 0){
oTable.fnDeleteRow($(this).parent().attr("id").replace("tr", ""));
$(".data-table tbody tr").removeAttr("id");
$(".data-table tbody tr").each(function(i){
$(this).attr("id", "tr" + (i));
});
$(this).text("$" + $(this).text());
};
});
} else if($(this).find("option:selected").val() == 3){
oTable.fnDraw(false);
$(".inv-amt").each(function(){
if(parseFloat($(this).text().replace("$", "").replace(",", "")) > 0){
oTable.fnDeleteRow($(this).parent().attr("id").replace("tr", ""));
$(".data-table tbody tr").removeAttr("id");
$(".data-table tbody tr").each(function(i){
$(this).attr("id", "tr" + (i));
});
$(this).text("$" + $(this).text());
};
});
};
});[/code]

So how can I get this accomplished? If filtering is the answer, that's fine, but I don't know how to filter values based on negative or positive values. I.e. $599.87 or $-999.00. What I'm doing works but only on the first selection. So if what I'm doing is good, please tell me how I can reset the DataTable prior to performing the functions. Thanks.

Replies

  • rksrks Posts: 5Questions: 0Answers: 0
    edited May 2013
    Edit: Mistake.
This discussion has been closed.