fnFilter() - Trying to return empty table

fnFilter() - Trying to return empty table

OmiOmi Posts: 1Questions: 0Answers: 0
edited November 2012 in General
I'm trying to build a datatable that loads up empty, but shows the results from an Ajax source upon request from viewusers(); Everything works, but I'm having trouble with a specific detail.

If I call viewusers() using a group_id that returns real rows and then feed it some bogus group_id, I would like the bogus group_id to return an empty set. What happens instead is the bogus call doesn't update the contents of the datatable since the working request.

Example:

---------

No data available in table

>> viewusers(obj, 1); // There is 1 row matching 1 at col 2
Row 1

>> viewusers(obj, 3); // There are 3 rows matching 3 at col 2
Row 3
Row 4
Row 5

>> viewusers(obj, 7); // No rows exist matching 7 at col 2. I'd like this to empty the table, instead the following persists:
Row 3
Row 4
Row 5

---------

I've tried using fnClearTable(false); to clear data on the client side, but I can't get the results I'm looking for no matter what approach I take. How should I be trying to go about doing this?

DataTable declaration
[code]oTable = $('#user_groups_rel').dataTable( {

"bPaginate": false,
"bLengthChange": false,

"bFilter": true,
"bSort": true,
"bInfo": true,
"bAutoWidth": false,
"bSortClasses": true,
"iDeferLoading": 0,

"sScrollY": "240px",

"bServerSide": true,
"sAjaxSource": "http://localhost/sa/api/json-getusers-groups",
"sServerMethod": "POST",

"sDom": 'TlfrtipS',

"oTableTools": {
"aButtons": [ "csv", "xls", "pdf" ],
"sSwfPath": "http://localhost/sa/media/swf/copy_csv_xls_pdf.swf"
}
});[/code]

Function to update the table:
[code]function viewusers(oTable, group_id) {
oTable.fnFilter(group_id, 2, false, false);
}[/code]

Thanks ahead to anyone who can help me out with this! =D
This discussion has been closed.