Hybrid View

  1. #1
    Sencha User
    Join Date
    Jul 2010
    Posts
    303
    Vote Rating
    0
    flamant is on a distinguished road

      0  

    Default fire click event on an element

    fire click event on an element


    Hi,

    I have set a click event on a panel this way :

    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]));
                                        }
                                    }
                                });
    afterwards I would like to fire this click event from Ext.getCmp('rowGridPanel_'+sptNbr+'_'+gridNbr+'_'+recordId).

    How can I do that ?

    Thank you in advance for your answers

  2. #2
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,483
    Vote Rating
    34
    Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    Just call the handler function.

  3. #3
    Sencha User
    Join Date
    Jul 2010
    Posts
    303
    Vote Rating
    0
    flamant is on a distinguished road

      0  

    Default


    I already tried Ext.getCmp('rowGridPanel_'+sptNbr+'_'+gridNbr+'_'+recordId).fireEvent('click'); but it doesn't work

  4. #4
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,483
    Vote Rating
    34
    Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    Call the handler!

    I'm really concerned about your nested, ID driven code...

    Code:
    'rowGridPanel_'+sptNbr+'_'+gridNbr+'_'+recordId
    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.

  5. #5
    Sencha User
    Join Date
    Jul 2010
    Posts
    303
    Vote Rating
    0
    flamant is on a distinguished road

      0  

    Default


    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.

  6. #6
    Sencha User darthwes's Avatar
    Join Date
    Mar 2010
    Posts
    633
    Vote Rating
    -13
    darthwes can only hope to improve

      0  

    Default


    @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.

    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
      }
    });
    (Untested)

    See? No need for ids.
    Wes

Similar Threads

  1. how to fire event on an element
    By flamant in forum Ext 3.x: Help & Discussion
    Replies: 12
    Last Post: 17 Oct 2010, 2:28 AM
  2. Replies: 3
    Last Post: 28 Aug 2010, 12:37 AM
  3. Dataview does not fire click or dblclick event
    By Bandorka in forum Ext 2.x: Help & Discussion
    Replies: 8
    Last Post: 25 Nov 2008, 2:02 PM
  4. Fire event on element
    By TrickOfTheMind in forum Ext 2.x: Help & Discussion
    Replies: 3
    Last Post: 28 Apr 2008, 7:23 AM

Thread Participants: 2

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar