Cookie has to many searchcols

Cookie has to many searchcols

wizzboywizzboy Posts: 5Questions: 0Answers: 0
edited April 2009 in General
Hi

I'm having a question about the cookie that is stored.

I'm using individual filtering and global filtering together.
This is the value in my cookie:
{"iStart": 0,"iEnd": 1,"iLength": 10,"sFilter": "ad","sFilterEsc": true,"aaSorting": [],"aaSearchCols": [ ['sta',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true],['',true]]}

Like you see is my aaSearchCols part to much. I've only 6 cols?
But when i do "oSettings.aoPreSearchCols.length" after the cookie loaded he's givin me 120 and everytime i refresh the number of cols is more. Now is already 150. When i delete the cookie the length starts again from 6

Can somebody help me?

Thanks in advance

Replies

  • allanallan Posts: 61,627Questions: 1Answers: 10,090 Site admin
    Yikes! Sorry about this - this is an error in DataTables 1.5 beta 6. The issue is that a new entry is always created when a new column is added - so the saved state always goes up by the number of columns in your table.

    I'll include the fix in the next release, but if you want to apply the fix immediatly, what to do is:

    Replace line 1646:
    oSettings.aoPreSearchCols[ oSettings.aoPreSearchCols.length++ ] = {

    With:
    oSettings.aoPreSearchCols[ oSettings.aoColumns.length-1 ] = {

    The down-side is that your huge cookie will be retained (although nothing will be done with the values with an index > than the number of columns). Ideally you should delete the cookie as well...

    Allan
  • wizzboywizzboy Posts: 5Questions: 0Answers: 0
    Hi

    Allan i tried your solution but that doesn't do the trick for me.
    Because then the individual inputfields are not being saved to the cookie!

    I changed
    oSettings.aoPreSearchCols.length
    IN
    oSettings.aoColumns.length

    in the funtion _fnSaveState.

    And this looks like it does the trick!

    Many thanx 4 your help the past days.

    In the past i used several other filter/sort table scripts but this is the best in my opinion.

    Good work
  • allanallan Posts: 61,627Questions: 1Answers: 10,090 Site admin
    Hi whizzboy,

    Oops - sorry. My fix was incomplete. The saved state was always being written over with a blank search... The fix to that is to check if it should add the new object or not. Just before the changed line from before you can insert:

    if ( typeof oSettings.aoPreSearchCols[ iLength ] == 'undefined' )

    Or if you have a working fix, keep using that :-)

    Allan
This discussion has been closed.