I am trying to refresh list view portlet via ajax after deleting one of the values in the success action.
How would you approach this in zurmo?
My first approach has been to:
1) Create the getDefaultRoute method as follows
protected function getDefaultRoute()
{
if (Yii::app()->request->getParam('redirectUrl') != null) {
return Yii::app()->request->getParam('redirectUrl');
}
elseif (!empty($this->params["relationModelId"]) && $this->params["relationModelId"] > 0) {
return Yii::app()->createUrl(
$this->params["relationModuleId"] . '/' . $this->controllerId . '/details/',
array('id' => $this->params["relationModelId"],
'portletId' => $this->params["portletId"],
'uniqueLayoutId' => $this->params["uniqueLayoutId"],
'clearCache' => '1'
));
}
else {
return Yii::app()->createUrl($this->params["relationModuleId"] . '/' . $this->controllerId);
}
}
2) then in the ajax scripts use the defaultroute as the redirect to refresh the portlet
protected function renderLink()
{
$ModelId = $this->params["relationModelId"];
$attribName = $this->params["relationAttributeName"];
$redirectUrl = $this->getDefaultRoute();
return CHtml::link("CBR",
"#",
array("onclick" => "DelSelDetailFRelation (this,'$attribName','$ModelId', '$redirectUrl')", "confirm" => "Are you sure you want to delete this detail?"));
}
protected function renderScripts()
{
Yii::app()->clientScript->registerScript('delSelDetailFromListViewScript',
"
function DelSelDetailFRelation(element,relName, invoiceId, redirectUrl)
{
$.ajax({
url : '" . Yii::app()->createUrl('c_invoicedetails/default/DelSelFRelListFromAjax') . "' ,
type : 'GET',
dataType : 'json',
data : {'checkedIds': document.getElementById('list-view-selectedIds').value, 'relName': relName },
success : function(data)
{
//refresh portlet
window.location.href = redirectUrl;();
},
error : function()
{
//todo: error call
}
});
}
",
CClientScript::POS_END);
}
Where redirect URL is like this
app/index.php/c_invoicehdrs/default/details?id=2&portletId=8&uniqueLayoutId=C_invoicehdrDetailsAndRelationsViewLeftBottomView_8&clearCache=1
Thanks










