But I don't know how to make the filters, how to comlete my actions. I use doctrine an Symfony 1.4
Thanks in advance
Here's my HTML code :
- Code: Select all
<div id="searchContact">
<table id="rechercheContact"></table>
<div id="ptoolbar" ></div>
</div>
Here's my JS code :
- Code: Select all
//contact
jQuery("#rechercheContact").jqGrid({
url:'contact_recherche?recherche='+chemin,
datatype: "json",
mtype:'GET',
loadtext: "Chargement",
height: 250,
jsonReader : {root:"cellule"},
emptyrecords: "Aucun enregistrement",
colNames:['Nom','Prenom','Localite','Code Postal','Commentaire'],
colModel:[
{name:'Nom',index:'Nom', sortable: false },
{name:'Prenom',index:'Prenom', sortable: false},
{name:'Localite',index:'Localite', sortable: false},
{name:'CodePostal',index:'CodePostal', sortable: false},
{name:'Commentaire',index:'Commentaire', sortable: false},
],
scrollOffset: 0,
sortname: 'Nom',
$sortorder: 'asc',
caption: "Contact(s)",
viewrecords: true
});
jQuery("#rechercheContact").jqGrid('navGrid','#ptoolbar',{del:false,add:false,edit:false,search:true});
jQuery("#rechercheContact").jqGrid('filterToolbar',{stringResult: true,searchOnEnter : false});
and finally my action:
- Code: Select all
public function executeTrouverContact(sfWebRequest $request) {
$this->contacts = Doctrine_Query::create()
->select()
->from('Contact c')
->where('nom LIKE \'%'.$request->getParameter('recherche').'%\'')
->orWhere('prenom LIKE \'%'.$request->getParameter('recherche').'%\'')
->orWhere('code_postal LIKE \'%'.$request->getParameter('recherche').'%\'')
->orWhere('localite LIKE \'%'.$request->getParameter('recherche').'%\'')
->orWhere('commentaire LIKE \'%'.$request->getParameter('recherche').'%\'')
->execute();
$inscriptions = array();
if ($request->isXmlHttpRequest()) {
if (!is_null($this->contacts) && !empty($this->contacts)) {
$id = 1;
foreach ($this->contacts as $contact) {
$inscriptions['cellule'][] = array(
'id' => "$id",
'cell' => array($contact->getNom(),$contact->getPrenom(),
$contact->getCodePostal(),$contact->getLocalite()
,$contact->getCommentaire())
);
$id++;
}
$this->getResponse()->setHttpHeader('Content-Type','application/json; charset=utf-8');
$inscriptions = $this->renderText(json_encode($inscriptions));
}
}
return $inscriptions;
}
