How to Change rowaction button based on condition in Subpanel ??

Hi Friends 

Contact -> RecordView

Cases -> Subpanel under contact record.

i want to change to rowaction button when case status is Closed in subpanel

for example ..

if case status closed then i want preview button else i want delete button as a rowaction.

i have made changes in 2 files ..but not working for me .. Please Help Ajay Kumar Ramana Raju Santhana

custom/modules/Cases/clients/base/views/subpanel-for-contacts-cases/subpanel-for-contacts-cases.php

$viewdefs['Cases']['base']['view']['subpanel-for-contacts-cases'] = array (
'panels' =>
array (
0 =>
array (
'name' => 'panel_header',
'label' => 'LBL_PANEL_1',
'fields' =>
array (
0 =>
array (
'label' => 'LBL_LIST_SUBJECT',
'enabled' => true,
'default' => true,
'name' => 'name',
'link' => true,
),
1 =>
array (
'label' => 'LBL_LIST_STATUS',
'enabled' => true,
'default' => true,
'name' => 'status',
),
2 =>
array (
'target_record_key' => 'account_id',
'target_module' => 'Accounts',
'label' => 'LBL_LIST_ACCOUNT_NAME',
'enabled' => true,
'default' => true,
'name' => 'account_name',
),
3 =>
array (
'name' => 'case_number',
'label' => 'LBL_NUMBER',
'enabled' => true,
'readonly' => true,
'default' => true,
),
4 =>
array (
'label' => 'LBL_LIST_DATE_CREATED',
'enabled' => true,
'default' => true,
'name' => 'date_entered',
),
5 =>
array (
'name' => 'assigned_user_name',
'target_record_key' => 'assigned_user_id',
'target_module' => 'Employees',
'label' => 'LBL_LIST_ASSIGNED_TO_NAME',
'enabled' => true,
'default' => true,
),
),
),
),
'rowactions' =>
array (
'actions' =>
array (
0 =>
array(
'type' => 'rowaction',
'tooltip' => 'LBL_PREVIEW',
'label' => 'LBL_PREVIEW',
'event' => 'list:preview:fire',
'icon' => 'fa-eye',
'acl_action' => 'view',
'allow_bwc' => false,
),
1 =>
array (
'type' => 'rowaction',
'name' => 'edit_button',
'icon' => 'fa-pencil',
'label' => 'LBL_EDIT_BUTTON',
'event' => 'list:editrow:fire',
'acl_action' => 'edit',
'allow_bwc' => true,
),
2 =>
array (
'type' => 'unlink-action',
'icon' => 'fa-chain-broken',
'label' => 'LBL_UNLINK_BUTTON',
),
),
),
'type' => 'subpanel-list',
);

custom/modules/Cases/clients/base/views/subpanel-list/subpanel-list.js

({ 
//subpanel-list.js
extendsFrom:'SubpanelListView',
initialize:function(options){
this._super('initialize',[options]);
this.on('render',this._disableActions,this);
},
_disableActions:function() {

console.log(this.context.attributes.collection.models);

//console.log(this.meta.rowactions.actions);
var self = this;

_.each(this.context.attributes.collection.models, function(case_model){
// console.log(case_model.get('status'));
if(_.isEqual(case_model.get('status'),'Closed'))
{
_.each(self.meta.rowactions.actions, function(action){
if(_.isEqual(action['icon'],"fa-eye")){ // for preview button
delete action['event'];
action['icon'] = 'fa-trash-o';
action['event'] = 'list:deleterow:fire';
action['name'] = 'delete_button';
action['acl_action'] = 'edit';
}
console.log(action);
});
}
});

}
})