Hybrid View
-
6 Nov 2010 10:13 AM #1
fire click event on an element
fire click event on an element
Hi,
I have set a click event on a panel this way :
afterwards I would like to fire this click event from Ext.getCmp('rowGridPanel_'+sptNbr+'_'+gridNbr+'_'+recordId).Code:newPanel = new Ext.Panel({ id: 'rowGridPanel_'+sptNbr+'_'+gridNbr+'_'+recordId, layout: 'absolute', recordId: recordId, rowSeq: rowSeq, x: 0, y: powerBuilderYUnitsToPixels(yMaxGridHeader-yMinGridHeader+i*(yMaxGrid-yMinGrid+30)), height: powerBuilderYUnitsToPixels(yMaxGrid-yMinGrid+30), items: formFields, listeners: { afterrender : function(scope) { var record = remoteGridJsonStore.getById(scope.recordId); if (record.get('markToDelete') == true) { scope.body.addClass('markToDelete'); } var elt = scope.getEl(); elt.on('click', clickFunction.createDelegate(scope, [sptNbr, gridNbr, scope.recordId,remoteGridJsonStore])); } } });
How can I do that ?
Thank you in advance for your answers
-
6 Nov 2010 11:10 AM #2
Just call the handler function.
Search the forum: http://www.google.com/coop/cse?cx=01...%3Az7of1ufqccu
Read the docs too: http://extjs.com/deploy/dev/docs/
Scope: http://extjs.com/forum/showthread.ph...642#post257642
-
6 Nov 2010 11:22 AM #3
I already tried Ext.getCmp('rowGridPanel_'+sptNbr+'_'+gridNbr+'_'+recordId).fireEvent('click'); but it doesn't work
-
6 Nov 2010 2:54 PM #4
Call the handler!
I'm really concerned about your nested, ID driven code...
It's in every snippet you post, and indicates a non OO design where everything is just "there" and has to be accessed through a complex web of IDs.Code:'rowGridPanel_'+sptNbr+'_'+gridNbr+'_'+recordId
Search the forum: http://www.google.com/coop/cse?cx=01...%3Az7of1ufqccu
Read the docs too: http://extjs.com/deploy/dev/docs/
Scope: http://extjs.com/forum/showthread.ph...642#post257642
-
7 Nov 2010 2:59 AM #5
Hi animal,
I called the handler and it works fine . Thanks a lot.
can you be more precise about your remark when you say that it indicates a non OO design. Can you give me an example.
-
7 Nov 2010 8:04 AM #6
@Flamant, the use of ids to select components is certainly acceptable. However, when you build your own extensions (objects) over the Ext library, you can use scope to find the important objects (this.ownerCt, this.getChild, this.store.get, rec.get("")), allowing you to remove ids from your components since you don't need to use them anymore, and making your system more whole and simpler to debug, read, and maintain.
(Untested)Code:MyNS.App.FieldSet = Ext.extend(Ext.form.FieldSet, { initComponent: function() { MyNS.App.FieldSet.superclass.initComponent.call(this); this.numFields = this.numFields || 4; this.buildFields(); this.on('customEvent', this.checkFields()); }, buildFields: function() { var iMax = this.numFields; for(var i = 0; i < iMax; i++) { this.add(new Ext.field.TextField({...}); } }, checkFields: function() { var myFields = this.items.items; //loop over them, whatever } });
See? No need for ids.
Wes
Similar Threads
-
how to fire event on an element
By flamant in forum Ext 3.x: Help & DiscussionReplies: 12Last Post: 17 Oct 2010, 2:28 AM -
Is this even possible create element and listening and fire event?
By Cyberangel67 in forum Ext: Q&AReplies: 3Last Post: 28 Aug 2010, 12:37 AM -
Dataview does not fire click or dblclick event
By Bandorka in forum Ext 2.x: Help & DiscussionReplies: 8Last Post: 25 Nov 2008, 2:02 PM -
Fire event on element
By TrickOfTheMind in forum Ext 2.x: Help & DiscussionReplies: 3Last Post: 28 Apr 2008, 7:23 AM


Reply With Quote