PDA

View Full Version : How to programmatically fire the check change event of a ExtJS 4.1 checkbox tree pane



webfriend13
5 Aug 2013, 7:05 AM
I have a ExtJs 4.1 check box tree panel. When I check or uncheck any node, check change event for the tree is fired. How can I programmatically fire this event.

One way I can think of is to use following code. But this code is not firing every time :-(

this.fireEvent('checkchange', node, true, opts);

Thank you

halcwb
5 Aug 2013, 1:28 PM
I have a ExtJs 4.1 check box tree panel. When I check or uncheck any node, check change event for the tree is fired. How can I programmatically fire this event.

One way I can think of is to use following code. But this code is not firing every time :-(

this.fireEvent('checkchange', node, true, opts);

Thank you

I think that is indeed the way to go. There is an option that makes sure that an event only gets fired once, you could experiment with just fireEvent('checkchange') without further arguments. Every time you call fireEvent, the event will be fired.

You can also use the below fiddle setup to experiment:

5r

webfriend13
6 Aug 2013, 12:34 AM
@halcwb: Thank you for quick reply. But calling by using this.fireEvent('checkchange') does not fire the event. I am using ExtJs 4.1

halcwb
6 Aug 2013, 1:10 AM
@halcwb: Thank you for quick reply. But calling by using this.fireEvent('checkchange') does not fire the event. I am using ExtJs 4.1

Maybe a bit semantic, but how can you be sure the event doesn't get fired. You only can be sure, if you're sure that a listener is attached to 'this' that is firing the event, and that a handler for the event is registered.

So, check this:



cmp.on('myownevent', function () { alert('this is my own event')});
cmp.fireEvent('myownevent');


In other words, somehow, nobody is listening to your event or the handler has a problem preventing it from executing.

P.s. Updated fiddler so you can check it yourself. Switch the framework in fiddler to see if it works in your framework version.