How to retain original view after action renders different layout element

64 views Asked by At

I have an action/view script that displays a table of rows, and each row is clickable: I want this action to update a particular div with more details of the row. However, when i do so, the original table is lost ( view is cleared) How can i get an action to render a particular script, but not effect the default layout container? ( layout->content() in this case) Note: I can use _forward() or similar, but I was wondering if there is a more elegant solution.

My controller detail action looks like this

public function detailAction()
{
    // action body
$clientModel = new Model_Clients();
$id = $this->_request->getParam('id');

// get the specific row by 'id'
try {
    $result = $clientModel->getClient($id);
    $this->view->result = $result;
} catch (Exception $e) {
    echo 'Error: ',  $e->getMessage(), "\n";
    //die();
}

$this->render('detail', 'mainContentRight');
//$this->listAction(); !This doesnt work!
$this->_forward('list'); // Nasty, but works.

}

The 'detail' refers to the view script of this action ( seems redundant) and 'mainContentRight' is the target layout element to update.

I think im missing a vital point in the view scripts, any advise is welcome.

1

There are 1 answers

1
s7anley On

After forwarding you still need same data for table as you have in listAction. Then table should be rendered properly, but I think better approach here is load detail information with AJAX.