Parameters for 2nd fnFilter() call contains parameters from previous calls?

Parameters for 2nd fnFilter() call contains parameters from previous calls?

tomaspet262tomaspet262 Posts: 3Questions: 0Answers: 0
edited September 2011 in General
1. I call fnFilter('term for one', 1)
2. I call another fnFilter('term for two', 2)

For second fnFilter() call, these parameters were sent to the server:

[code]
...

sSearch_1: 'term for one'
bRegex_1: false
bSearchable_1: true

sSearch_2: 'term for two'
bRegex_2: false
bSearchable_2: true

...
[/code]

=> Params from previous searches are included. Is it possible to have params only from current call? In the manner that params send to server for second fnFilter() call would be:

[code]
...

sSearch_1: ''
bRegex_1:false
bSearchable_1:true

sSearch_2: 'term for two'
bRegex_2: false
bSearchable_2: true

...
[/code]

Thanks in advance.

Replies

  • fbasfbas Posts: 1,094Questions: 4Answers: 0
    you can reset previous filters

    fnFilter('',1);
    fnFilter('term for two', 2);
  • tomaspet262tomaspet262 Posts: 3Questions: 0Answers: 0
    edited September 2011
    I have 5 possible filters. With each request for filtering, I will have to call 5 ajax-requests (4 for others + 1 for global search) and then call 6th = it is overkill for database and time-consuming for client.

    Maybe, if there would be option to pass all params within one call, it will be good solution.
  • fbasfbas Posts: 1,094Questions: 4Answers: 0
    ahh, that's a good point

    http://www.datatables.net/plug-ins/api#fnMultiFilter
  • tomaspet262tomaspet262 Posts: 3Questions: 0Answers: 0
    edited September 2011
    Thanks for the link, I have completely overlooked the Plug-in section.

    Anyway, I did it with adding 3 lines of code in the jquery.dataTables.js, within this.fnFilter function, starting on line 1560:
    [code]
    /* Delete previous single-column searches */
    for(var i in oSettings.aoPreSearchCols)
    oSettings.aoPreSearchCols[ i ].sSearch = '';
    oSettings.oPreviousSearch.sSearch = '';
    [/code]

    Nevertheless, thank you for you time and tips!
This discussion has been closed.