_fnFilter broken in 1.9.0?

_fnFilter broken in 1.9.0?

bloodersblooders Posts: 10Questions: 0Answers: 0
edited January 2012 in Bug reports
I don't know if this is by design but the internal API method _fnFilter behaves differently between versions 1.8.x and 1.9.0b4. A table is not updated with unfiltered data if you use this method to clear a previous filter. The difference between versions is that the previous filter values (specifically the text) are no longer set prior to returning from the function.

The external API method fnFilter behaves as expected.

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    I'm just looking at the code for 1.8.2 and I'm surprised that _fnFilter caused a redraw at all - it shouldn't have done and I can't see the code that would have caused it to do so. Are you calling something else as well?

    Having said that, as you note _fnFilter is an internal function and its behaviour is liable to change between versions. The external API will always be stable and that is what should be used where possible. If the external API doesn't provide what is needed an API plug-in can be created that does use the internal methods, but that must be tested between versions, since that internal API can and will change (otherwise DataTables wouldn't be able to progress in development!).

    Regards,
    Allan
  • bloodersblooders Posts: 10Questions: 0Answers: 0
    Hi Allan,

    Sorry if I wasn't clear. It's not where the redraw is triggered from. It was just the fact that if you now use _fnFilter to clear a previous filter, the cleared filter is not reflected in the displayed lists when the table is eventually redrawn.
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Ah I see what you mean. This is now done in the _fnFilterComplete internal function: https://github.com/DataTables/DataTables/blob/master/media/src/core/core.filter.js#L73 . So all behaving as expected, its just a functional difference between 1.8- and 1.9+. The intention was to save a little bit of time with server-side processing to stop the client doing filtering that is irrelevant and avoid code duplication. It might be better for me in future to dump that inner function into another private function. So this might well change again in 1.10+.

    As I say, using the public API methods are very much the way to go if it is possible to use them!

    Allan
This discussion has been closed.