Question

Hello I a little problem with my paginator, i would like to use some custom SQL Request but each time i click on a paginator link it loads my model without the custom request

I enter informations on a form that I send by GET method:

$view->grid->js()->reload(array("From" => 
  $form->get("From"),"To" => $form->get("To"),"SSID" => $form->get("SSID")))
  ->execute();

On my view I have :

  $this->request=$this->api->db->dsql();        
  $this->grid=$this->add('Grid');
  $this->grid->setModel('Systemevents',array('ID','ReceivedAt','Message'));
  $this->grid->addPaginator(10);

  if (isset($_GET["SSID"])) {
     $this->ssid = $_GET["SSID"];       
  }
  if (isset($_GET["From"])) {
     $this->from = $_GET["From"];           
  }
  if (isset($_GET["To"])) {
     $this->to = $_GET["To"];            
  }

   $this->grid->dq->where($this->requette->expr('Message like "%.% ' 
        . $this->ssid . ' % src=%"'))
        ->where($this->requette->expr("ReceivedAt >= '".$this->from. "' 
          AND ReceivedAt <= '".$this->to."'"));

The problem is that the where condition disapear when i change the page with the paginator.

Was it helpful?

Solution 2

Finally the ultimate solution was to do :

if ((isset($_GET["SSID"])) || (isset($_GET["From"])) || (isset($_GET["To"]))) { 
//GET Method from Recherche.php

  $this->ssid     = ($_GET["SSID"]    == "null" ? null : $_GET["SSID"]);
  $this->api->stickyGET("SSID"); // the solutiuon is here
  $this->from     = ($_GET["From"]    == "null" ? null : $_GET["From"]);            
  $this->api->stickyGET("From"); // <===== the solutiuon is here         
  $this->to       = ($_GET["To"]      == "null" ? null : $_GET["To"]);
  $this->api->stickyGET("To"); // <===== the solutiuon is here 

}

OTHER TIPS

I did not found any solution to my problem so I have done something differently

I added two buttons to my grid wich allows me to change the limit of the sql request.

The previous button is hidden if the limit is 0.

Now i have to found how to count the number of lines (select count('ID') from 'SystemEvents' where....) and to stock it in a variable.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top