I'm trying to hide /show two buttons in grid depending on a method from the controller. Here is my grid actions and actionscolumn:
actions: {
run: {
iconCls: 'u4f-backgroundjobs-start-icon',
tooltip: U4.Titles.getTitle(20637, 'Run'),
handler: 'onRunClick',
isActionDisabled: 'isRunDisabled'
},
pause: {
xtype: 'u4_button',
iconCls: 'u4f-backgroundjobs-pause-icon',
padding: 0,
width: 15,
height: 15,
tooltip: U4.Titles.getTitle(60600, 'Hold'),
handler: 'onPauseClick',
hidden: 'isPauseHidden'
},
kill: {
iconCls: 'u4f-backgroundjobs-kill-icon',
tooltip: U4.Titles.getTitle(39340, 'Terminate'),
handler: 'onKillClick',
isActionDisabled: 'isKillDisabled'
},
resume: {
xtype: 'u4_button',
iconCls: 'u4f-backgroundjobs-resume-icon',
padding: 0,
width: 15,
height: 15,
handler: 'onResumeClick',
hidden: 'isResumeHidden'
}
},
Column:
{
text: U4.Titles.getTitle(47035, 'Actions'),
menuDisabled: true,
sortable: false,
xtype: 'actioncolumn',
flex: 2,
// items: ['@run', '@pause', '@kill'],
items: ['@run', '@pause', '@resume', '@kill'],
draggable: false,
resizable: false,
align: 'center'
},
Here are examples of functions in the controller for the 'isActionDisabled' and 'hidden' properties:
isRunDisabled: function (grid, rowIndex) {
var me = this,
gridStore = grid.getStore(),
storedTask = gridStore.getAt(rowIndex),
jobCanRunOnDemand = storedTask.get('canRunOnDemand');
return me.jobIsRunning(grid, rowIndex) || !jobCanRunOnDemand;
},
isResumeHidden: function (grid, rowIndex) {
var me = this,
gridStore = grid.getStore(),
storedTask = gridStore.getAt(rowIndex),
jobStatus = storedTask.get('jobStatus'),
activeToTime = storedTask.get('activeToTime'),
currentTime = new Date();
return jobStatus === 0 || activeToTime < currentTime;
},
For some reason the 'isActionDisabled' property is working as intended but the 'hidden' property is not. It's only returning true no matter what I alter in the return of those methods. The problem is that I don't want to disable them this time, I want to hide and show dynamically. Am I doing something wrong or missing something? Is there any other kind of approach to it? Thank you in advance.