Jump to content


datatables cache

datatables search input cache text reload page

  • Please log in to reply
21 replies to this topic

#1 stefano.papaleo

stefano.papaleo

    Member

  • Members
  • PipPip
  • 11 posts

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



#2 davidoster

davidoster

    Grocery CRUD Ninja

  • Advanced Member
  • PipPipPip
  • 1,068 posts
  • LocationAthens, Greece

Posted 07 February 2013 - 01: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!


____________________________________________________________

 

rtfm_small.jpg---!!!Please read these guidelines before asking to the forums!!!---

____________________________________________________________

 

David Oster aka George Pasparakis,
http://odphotography.com
http://eletter.gr


#3 victor

victor

    grocery CRUD Hero

  • Advanced Member
  • PipPipPip
  • 967 posts
  • LocationMinsk

Posted 07 February 2013 - 01:40 PM

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



#4 davidoster

davidoster

    Grocery CRUD Ninja

  • Advanced Member
  • PipPipPip
  • 1,068 posts
  • LocationAthens, Greece

Posted 07 February 2013 - 02:26 PM

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

Hahahahahaha victor we were replying at the same time!!!


____________________________________________________________

 

rtfm_small.jpg---!!!Please read these guidelines before asking to the forums!!!---

____________________________________________________________

 

David Oster aka George Pasparakis,
http://odphotography.com
http://eletter.gr


#5 victor

victor

    grocery CRUD Hero

  • Advanced Member
  • PipPipPip
  • 967 posts
  • LocationMinsk

Posted 07 February 2013 - 02:32 PM

;-)

#6 stefano.papaleo

stefano.papaleo

    Member

  • Members
  • PipPip
  • 11 posts

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



#7 victor

victor

    grocery CRUD Hero

  • Advanced Member
  • PipPipPip
  • 967 posts
  • LocationMinsk

Posted 08 February 2013 - 11:20 AM

As I see the datatables theme use the local storage.

#8 stefano.papaleo

stefano.papaleo

    Member

  • Members
  • PipPip
  • 11 posts

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?


#9 victor

victor

    grocery CRUD Hero

  • Advanced Member
  • PipPipPip
  • 967 posts
  • LocationMinsk

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:

storage.jpg



#10 stefano.papaleo

stefano.papaleo

    Member

  • Members
  • PipPip
  • 11 posts

Posted 08 February 2013 - 02:33 PM

here it is

Attached Thumbnails

  • cookie.PNG


#11 stefano.papaleo

stefano.papaleo

    Member

  • Members
  • PipPip
  • 11 posts

Posted 13 February 2013 - 04: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..

Attached Thumbnails

  • chrome.PNG


#12 victor

victor

    grocery CRUD Hero

  • Advanced Member
  • PipPipPip
  • 967 posts
  • LocationMinsk

Posted 13 February 2013 - 04: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>
 


#13 victor

victor

    grocery CRUD Hero

  • Advanced Member
  • PipPipPip
  • 967 posts
  • LocationMinsk

Posted 13 February 2013 - 05:09 PM

I think it will help you



#14 stefano.papaleo

stefano.papaleo

    Member

  • Members
  • PipPip
  • 11 posts

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!



#15 victor

victor

    grocery CRUD Hero

  • Advanced Member
  • PipPipPip
  • 967 posts
  • LocationMinsk

Posted 14 February 2013 - 08:25 AM

show url which you get

#16 stefano.papaleo

stefano.papaleo

    Member

  • Members
  • PipPip
  • 11 posts

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

Attached Thumbnails

  • url.jpg


#17 victor

victor

    grocery CRUD Hero

  • Advanced Member
  • PipPipPip
  • 967 posts
  • LocationMinsk

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.

#18 victor

victor

    grocery CRUD Hero

  • Advanced Member
  • PipPipPip
  • 967 posts
  • LocationMinsk

Posted 14 February 2013 - 09:13 AM

try that.

#19 stefano.papaleo

stefano.papaleo

    Member

  • Members
  • PipPip
  • 11 posts

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 ;)



#20 stefano.papaleo

stefano.papaleo

    Member

  • Members
  • PipPip
  • 11 posts

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!







Also tagged with one or more of these keywords: datatables, search, input, cache, text, reload, page

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users