⚠ 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

Problem "multiples" where with "post"



darioravello
  • profile picture
  • Member

Posted 01 March 2014 - 17:23 PM

After reading a lot in the forum, i can't find the solution to my problem.
I'm trying to make a grid only for show, print and export. But I don't know why something weird happens.
The result shows ok at the first time for a few seconds, and then (like a refresh) show all the registres cleaning the filtres. (in the next time doesn't work directly)
The filtres are by post and multiple "where".
 
I have read a lot but, i dont know if the solution is:
1) If the problem it's the way and i need to make it with a "model" and a custom query.
2) If the problem it's that the "grocery crud" don't support  this function.
3) Or i need to save de "post" in a "session variable" for not disappear.
4) If the main problem it's in some cookie....
 
If somebody had the same problem and know the solution, a little guide for how to do it.
 
SOMEBODY CAN HELP ME? I'M BREAKING MY HEAD.
(Sorry for my English, I'm from Argentina)

 

 


Amit Shah
  • profile picture
  • Member

Posted 02 March 2014 - 21:32 PM

Hi darioravello

 

I don't really thing the GC is not supporting multiple wheres...

But yes i will like to share you some insights with what may be going wrong... Correct me if i am wrong - the 1st time when u hit the page - u may get the filtered data ..and suddenly u might notice the data vanished / refreshed... or . if u click on second page - u might notice the where clause applied vanishes.

 

In either of the case i will like you to share as why it would be happening.. When u 1st land on the page - u have all the variables u planning to apply in as filter and u apply the same with criteria / condition. Next any request - the code is not able to find any such parameters - so it skips in any such where clause that needs to be applied. Here is where the trouble / catch is ... GC is an Ajax driven solution and it keeps making ajax queries / requests to retrieve in data. It dose not append to the previous post received to the page for rendering. Hence yes the solution i see to this is maintain the search parameters into session. If in case you dont find the search parameters being sent from search form - u retrieve the same from session ... and in case if u find the params from search form.. reset the session values for the same.

 

This way u wil make sure that every request is filtered properly.. even if its an ajax request from GC

 

Hope this solves yr issue...

 

Happy GCing :)


Paul Savostin
  • profile picture
  • Member

Posted 15 May 2014 - 01:23 AM

Hi darioravello

 

I don't really thing the GC is not supporting multiple wheres...

But yes i will like to share you some insights with what may be going wrong... Correct me if i am wrong - the 1st time when u hit the page - u may get the filtered data ..and suddenly u might notice the data vanished / refreshed... or . if u click on second page - u might notice the where clause applied vanishes.

 

In either of the case i will like you to share as why it would be happening.. When u 1st land on the page - u have all the variables u planning to apply in as filter and u apply the same with criteria / condition. Next any request - the code is not able to find any such parameters - so it skips in any such where clause that needs to be applied. Here is where the trouble / catch is ... GC is an Ajax driven solution and it keeps making ajax queries / requests to retrieve in data. It dose not append to the previous post received to the page for rendering. Hence yes the solution i see to this is maintain the search parameters into session. If in case you dont find the search parameters being sent from search form - u retrieve the same from session ... and in case if u find the params from search form.. reset the session values for the same.

 

This way u wil make sure that every request is filtered properly.. even if its an ajax request from GC

 

Hope this solves yr issue...

 

Happy GCing :)

Wow!!! Amit Shah you are the best one! About a half day looking answer why my post data vanish when i am using flexigrid theme and you  saved me again! Many thanks!!!

But solution for me was like this one:

 if($this->input->post('srch')){

            $this->session->set_flashdata('srch',$this->input->post());
             
        } else if($this->session->flashdata('srch')){

            $this->session->set_userdata('srch',$this->session->flashdata('srch'));
       
        } else if($this->session->userdata('srch')){
            
            $this->post_srch = $this->session->userdata('srch');
            
            $this->session->unset_userdata('srch');
            
        }
Why so? because I saw in firebug tha GC make 3 requests for some reason ( I just don't have а strong knowledge about this all stuff for now - let's say I am a newbie)

 

 

 

1)First request ---- check if was send form after submit filter values from form save them into flashdata, course if I save into just session I wouldnt figure out when them delete

2)Second request -------- then check if is flashdata was set before, then save normally to normal session

3)And finaly Third request ------ check if was set session userdata and assign it to the class variable $this->post_srch which one I use in my many "where" conditions. After that I remove session data.

This works for me! Maybe exists an easier solution but I don't know how. Just tell me what you think? how would you do ?

thanks in advance!

P.S. Like Britney sings "Oops you did it again, just saved me again!" :) Thanks man

 

 

EDIT: But simple and the best choice i guess, just save POST search data to the session and make button like CLEAR SEARCH which just unset session data with post search.

 


Amit Shah
  • profile picture
  • Member

Posted 15 May 2014 - 06:09 AM

Well happy to help you my friend :) and happy that you found a solution.

and Happy GCing :)