Looking for links for zend framework ajax table refresh
As you maybe aware from the following post I'm new to the Zend framework and web programming so any help is greatly appreciated.
What I want to do is have a page that my users can search for clients stored on the database have the results returned via a table. I know how to do this in a traditional form -> post -> results page manner but I would like to implement the following:
Have two or more Dojo autocomplete combo boxes that the user can enter search criteria into (I've found examples of this on the web and should be ok implementing this.)
Use the text entered into the query the clients table in the DB.
Return the results in a table on the same page without having to redirect, and if possible have the table update the results as the user types into the combo boxes. for example if the user types "Fa" for example the table will have "Farrell "Fagan" "Farrelly" As the user continues to type eg "Far" the table will have "Farrell" "Farrelly"
As you may have already guessed I need help with parts two and three. I've tried searching using keywords refresh and autocomplete but I've been unable to find anything that comes close to what I need.
Can anyone please provide links to tutorials/examples of how to do this in the Zend Framework. I know code is a lot to ask for but if anyone is feeling generous go ahead. Just in case it makes a difference I'm using Doctrine ORM 开发者_如何学Cto handle my models.
Thanks in advance for any replies.
Graham
The basic gist is this...
- Using the
AjaxContext
helper, add anhtml
context to your action. - Move your table markup into a
.ajax.phtml
file and replace it in your normal view with arender
call
Example
<?php echo $this->render('controller-name/action-name.ajax.phtml') ?>
- Add your JavaScript event handlers to the page. When requesting the AJAX content, add a
format=html
parameter to the request. This will trigger theAjaxContext
helper, returning only your table markup which you can then inject into the page.
The best part about this approach is that it degrades gracefully. If JavaScript is disabled or not available, the page reverts to the old school form -> post -> results method.
Have a look at my AJAX pagination post here for some pointers - http://blog.philipbrown.id.au/2011/03/awesome-pagination-with-zf-paginator-ajaxcontext-and-the-html5-history-api/
This uses a page
parameter in the same way you want to use your search criteria so it should do as a base reference.
精彩评论