⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

datatables cache



stefano.papaleo

stefano.papaleo
  • profile picture
  • Member

Posted 07 February 2013 - 12:00 PM

Hi all.

 

I am using datatables as default theme.

I noticed that if i search something in the input text on the upper-right corner, then change page and return on the previous page (not whit the "back" button on my browser, but with a link), my previous search is still there.

 

Even if i clear my browser cache, or close and restart the browser, my search is still there.

Same thing for the "Show X Entries" dropdown.

 

Is possible to disable this type of "caching"?

 

Thanks,

 

Stefano


davidoster

davidoster
  • profile picture
  • Member

Posted 07 February 2013 - 13:35 PM

This is the mechanism of cookies behind the grocery crud library itself that the creator has implemented in order to have persistent view even when changing pages!!!

This is a great feature to be honest, at least from my point of view. On the very far end of the header there is a button that clears the filtering and initializes the list to it's initial status(no filtering).

 

By code I have no idea how this could be done, unless you inspect the code that runs under this button that clears the results and implement it within your controller function!


victor

victor
  • profile picture
  • Member

Posted 07 February 2013 - 13:40 PM

the search uses cookies. you can make a function which will be clear search value from it.


davidoster

davidoster
  • profile picture
  • Member

Posted 07 February 2013 - 14:26 PM

the search use cookies. you can make a function which will be clear search value from it.

Hahahahahaha [member="victor"] we were replying at the same time!!!


victor

victor
  • profile picture
  • Member

Posted 07 February 2013 - 14:32 PM

;-)

stefano.papaleo

stefano.papaleo
  • profile picture
  • Member

Posted 08 February 2013 - 10:38 AM

Yes, it's a good feature, but i use grocery crud called in an fancybox iframe to add row in invoices.

In this case is uncomfortable delete every time the previous search from the goods table.

 

How can i "clear search value from the cookies"? I need the name of the cookie for doing it, i am right?

I found this jquery command:

 

$.cookie("name", null);

 

Thanks for the replies

 

Stefano


victor

victor
  • profile picture
  • Member

Posted 08 February 2013 - 11:20 AM

As I see the datatables theme use the local storage.

stefano.papaleo

stefano.papaleo
  • profile picture
  • Member

Posted 08 February 2013 - 11:52 AM

As I see the datatables theme use the local storage.

 

What do you mean with "local storage"

 

I searched in chrome's cookies and i found a cookie called "SpryMedia_DataTables_groceryCrudTable_cerca_articoli". (cerca_articoli is the name of the function of the codeigniter controller)

 

I have downloaded jquery plugin, loaded into my page and inserted this line every time that the fancybox is closed:

 

 

$.removeCookie('SpryMedia_DataTables_groceryCrudTable_cerca_articoli').

 

But the cookie is still there. 

 

Tried with:

 

if($.removeCookie('SpryMedia_DataTables_groceryCrudTable_cerca_articoli'))
     alert('yeah');
else
     alert('ouh no');
 

 

 
and the result is" ouh no", so this command seems to not working.
 
Suggestions?

victor

victor
  • profile picture
  • Member

Posted 08 February 2013 - 12:12 PM

what value does have the SpryMedia_DataTables_groceryCrudTable_cerca_articoli?

webstorage.

In my case localstorage keeps settings of datatables.

You can see it  in this image:

[attachment=461:storage.jpg]


stefano.papaleo

stefano.papaleo
  • profile picture
  • Member

Posted 08 February 2013 - 14:33 PM

here it is


stefano.papaleo

stefano.papaleo
  • profile picture
  • Member

Posted 13 February 2013 - 16:41 PM

i have read the article on wikipedia but... i haven't understood what i might do to unset this cookie..

 

i searched into chrome local storage, but is empty. see in the image below

 

if i right-click on that value, and click delete, my previous search is deleted. i only want to do this from my script..


victor

victor
  • profile picture
  • Member

Posted 13 February 2013 - 16:53 PM

As solution you can add the uncial hash-segment to url in your menu.

for example:

 

<div id="left menu">
<a href="...">articles</a>
<a href="....">categories</a>
<a href="your_controller/function/<?=time()?>">YOUR PROBLEM </a>
</div>
 

victor

victor
  • profile picture
  • Member

Posted 13 February 2013 - 17:09 PM

I think it will help you


stefano.papaleo

stefano.papaleo
  • profile picture
  • Member

Posted 14 February 2013 - 08:12 AM

i tried this before open the topic... added a variable "junk" with a random value... doesn't work!


victor

victor
  • profile picture
  • Member

Posted 14 February 2013 - 08:25 AM

show url which you get

stefano.papaleo

stefano.papaleo
  • profile picture
  • Member

Posted 14 February 2013 - 08:39 AM

this is the link.. it's a series of link (one of each row of invoice), everyone has "junk" set to a random number


victor

victor
  • profile picture
  • Member

Posted 14 February 2013 - 09:12 AM

no,your solution is wrong. you should use the hash as segment. <a href="your_controller/
function/hash/">YOUR
PROBLEM </a>. the grocery crud works fine with extra segments.

victor

victor
  • profile picture
  • Member

Posted 14 February 2013 - 09:13 AM

try that.

stefano.papaleo

stefano.papaleo
  • profile picture
  • Member

Posted 14 February 2013 - 09:50 AM

i will try that as soon as possible and let you know.

 

for now thanks for the help ;)


stefano.papaleo

stefano.papaleo
  • profile picture
  • Member

Posted 14 February 2013 - 10:55 AM

it works!  B)

 

it's normal that now is not saved any cookie for that table? anyway, thanks a lot for the help!