I am trying to implement a search form which would show results gotten from the db when given (a) keyword(s), then updating a grid or lister with the search results.
Only i’m a bit lost as to how to update the grid…
I’ve looked at some similar questions (ie: How to refresh grid after update from modal form in atk4? ) but I can’t seem to get the grid to update after submitting my form.
code follows, any tips on what i’m doing wrong, or a better way to do this?
later i’d like the search and update several grids/listers from different db tabels, but if I’d get one to work that would already be a start… 🙂
$f=$this->add('Form');
$f->addField('Search','buscar', 'Enter keywords:');
$f->addSubmit('Search');
$g=$this->add('Grid');
$g->js(true)->addClass('myreload');
$g->js('myreload')->reload();
$g->setSource('conflicto');
$g->addColumn('nombre');
$g->addColumn('idconflicto');
if($f->isSubmitted())
{
$keywords=$f->getElement('buscar')->get();
$g->dq->where("nombre LIKE '".$keywords."'");
$this->js(null,$this->js()->_selector('.myreload')->trigger('myreload')) ->univ() ->closeDialog() ->successMessage('Actualizado') ->execute();
}
okay, so what you should do is following:
not tested, but should work.