Quantcast
Channel: DataTables 1.9 — DataTables forums
Viewing all articles
Browse latest Browse all 1816

afnFiltering.push() filtering issue

$
0
0
I am using version 1.9.4 and attempting to do some custom sorting on a table. I have two selects that I am getting options from to filter a table based on some data attributes in the rows.

I have two issues.

1) When I check one or more options and then sort using the column heading sort tools the table resets to show all records. Do I need to call the .push() function again after having the table sort?

2) The custom filters only work with a single option. I am storing the data from the checked inputs into two global variables

[code]
selectSchoolFilters = $.map($('#for_school input:checked'), function(e) { return e.value })
selectTypeFilters = $.map($('#for_type input:checked'), function(e) { return e.value })

listTable.dataTable().fnDraw(true)
[code]

I then test to see if the rows data-type attribute is one of the items in the array (excuse the newbie code. I write for legibility :-)

[code]
$.fn.dataTableExt.afnFiltering.push(

function(oSettings, aData, iDataIndex) {

var tr = $(oSettings.aoData[iDataIndex].nTr)
if(!tr.closest('table').is('#card_list_table')) {
return true
}

var typePassed = true

// don't do anything if the type filters array is empty
if (selectTypeFilters.length) {

var listIndex = $.inArray(tr.data('type'), selectTypeFilters)
if (listIndex == -1) {
typePassed = false
}

}

var schoolPassed = true

if (selectSchoolFilters.length) {
// nothing here yet
}

return typePassed && schoolPassed

}
)
[code]

When I debug this or use the console to output the variable in play it appears to work but anything other than a single value in the selectTypeFilters array will cause the table to display data that is not one of the options selected.

I've tried several different options and nothing seems to work.

Any comments or suggestions would be appreciated.

You can see an older version of this with the same issues at

http://wp.arcanewonders.com/mw/mw.php

Select a "Mage" to show the table in question

Viewing all articles
Browse latest Browse all 1816

Trending Articles