Feb 17, 2014, 3:54 PM
[CLOSED] Question on Using simple plugin to perform basic setDisable task
Ext.form.btnToggleTarget = function(config) {
Ext.apply(this, config);
}
Ext.form.btnToggleTarget = Ext.extend(Ext.Button,
{
target: null,
init: function(config) {
Ext.apply(this, config);
this.target = Ext.getCmp(this.targetid).selModel;
this.target.on('selectionchange', this.autoToggle, this);
this.setDisabled(true);
},
autoToggle: function() {
// this.setDisabled(!Ext.isEmpty(this.target.getSelected()));
this.setDisabled(false);
}
});
Ext.preg('btnToggleTarget', Ext.form.btnToggleTarget);
<ext:Button ID="RXDeleteButton" IDMode="Explicit" runat="server" Text="Delete this medication" Icon="Delete">
<CustomConfig>
<ext:ConfigItem Name="targetid" Value="MedGrid" Mode="Value" />
</CustomConfig>
<Plugins>
<ext:GenericPlugin runat="server" InstanceName="Ext.form.btnToggleTarget" ID="btnToggleTgt">
</ext:GenericPlugin>
</Plugins>
</ext:Button>
I need to venture into the world of plugins so I figured I'd start off simple and work my way up. I don't fully grasp the sequence of events in using a plugin. All I'm trying to do is add functionality to a specific button (hence the use of plugin) so I can set it up to listen for a change on a grid and disable or enable based on a valid selection. While this code doesn't give me any errors, it also does not enable or disable the button which the plugin is attached to. I'm sure I'm doing something wrong and I'm just not seeing the obvious. Any pointers? FYI: I commented out the operational code that does the setDisable in lieu of forcing a disable to see if that worked and it didn't. But if I call setDisable in the browser console, it works fine. So I think what is going on is that the apply stuff is not applying in the proper hierarchical direction.. ? if so, then I am fundamentally misunderstanding how to write plugins, in which case, I need some directions on how to do this properly.
Thanks
Last edited by Daniil; Feb 18, 2014 at 6:15 AM.
Reason: [CLOSED]