PDA

View Full Version : Disable grid CRUD buttons based upon return from function



Bob Mutascio
29 Jun 2015, 1:51 PM
I'm having trouble figuring out how to disable or hide the add, edit and delete buttons in my grid. I have a security check to determine whether a user has CRUD abilities. This is what I have in my grid's onFileGridRender. I've tried all these different ways to hide or disable it, but none has worked. Thanks for any help you can give.

Ext.Ajax.request({
url: '/valence/vvcall.pgm',
params: {
pgm: 'CX0028',
action: 'CheckAuthorization',
},
success: function(response, opts) {
var obj = Ext.decode(response.responseText);
if (response.responseText == '{"success":false}') {
Ext.Msg.alert('Return Status', response.responseText);
//Ext.get('addbutton').setVisible(false);
//Ext.container.Container.getComponent('#addbutton').Disabled(true);
//Ext.ComponentQuery.query('#Addbutton')[0].hidden=true;
//Ext.ComponentQuery.query('#Addbutton')[0].hide();
//Ext.ComponentQuery.query('Addbutton')[0].hidden=true;
//Ext.ComponentQuery.query('Addbutton')[0].hide();
//Ext.ComponentQuery.query('Addbutton').hidden=true;
//Ext.ComponentQuery.query('Addbutton').hide();
addbutton.Disabled(true);
}}
});

tristan.lee
29 Jun 2015, 1:59 PM
Take a look at this method for disabling a Button component: http://docs.sencha.com/extjs/3.4.0/#!/api/Ext.Button-method-disable

Bob Mutascio
29 Jun 2015, 2:55 PM
I tried Ext.Button('#addbutton').Disabled(true); and Ext.Button('addbutton').Disabled(true); Button still enabled. How about an actual example?

tristan.lee
30 Jun 2015, 6:30 AM
I'm not sure where you are pulling the Disabled method from. The link I provided to the API points to disable();

plj