1. #1
    Touch Premium Member
    Join Date
    Aug 2010
    Location
    New York, NY
    Posts
    66
    Answers
    2
    Vote Rating
    0
    sandeep45 is on a distinguished road

      0  

    Question Unanswered: how to do a complex query in the refs property of a controller?

    Unanswered: how to do a complex query in the refs property of a controller?


    Lets say I have a panel with a few buttons defined like this:

    Code:
    Ext.define('Desk.view.Case', {
    	extend: 'Ext.Panel',
            xtype: 'casesPanel'
            config: {
    		items:[
    			{
    				xtype:'button',
    				text:'i am a button'
                            },
    			{
    				xtype:'button',
    				text:'i am a button'
                            },
    
    
    			{
    				xtype:'button',
    				text:'i am a button'
                            }
           }
    });
    Now in my controller i want to have a ref to the second button. How would i do that? This is what I thought would work, but it doesn't?

    Code:
    Ext.define("Desk.controller.CaseCarousel", {
    	extend: "Ext.app.Controller",
    	config: {
    		refs: {
    		       casesPanel: 'casesPanel',	
                           button2: 'casesPanel button[1]'
                    },
                    control: {
                            button2: {
                                       tap: 'bla'
                            }
                    }
            }
    });
    To get around this issue, I have been doing the look up in the "launch" function of the controller. I am not sure if this is the correct/recommended way and thus am making this post.

    Code:
           launch: function(){
    		var secButton = this.getCasesPanel().query("button")[1];
    		secButton.on("tap", bla, this);
    	}
    Thanks

  2. #2
    Sencha User jerome76's Avatar
    Join Date
    Apr 2012
    Location
    New Jersey
    Posts
    1,135
    Answers
    129
    Vote Rating
    99
    jerome76 is just really nice jerome76 is just really nice jerome76 is just really nice jerome76 is just really nice jerome76 is just really nice

      0  

    Default


    Why don't you reference the buttons by their itemId?

  3. #3
    Touch Premium Member
    Join Date
    Aug 2010
    Location
    New York, NY
    Posts
    66
    Answers
    2
    Vote Rating
    0
    sandeep45 is on a distinguished road

      0  

    Default


    Usings ids is not cool coz if i make instances of this panel then all instances will have the same id

    i could use like a name or some other attribute, but this is an example. i am interested in learning how others r doing complex queries to find components like one does in DomQuery.

    Quote Originally Posted by jerome76 View Post
    Why don't you reference the buttons by their itemId?

  4. #4
    Sencha User jerome76's Avatar
    Join Date
    Apr 2012
    Location
    New Jersey
    Posts
    1,135
    Answers
    129
    Vote Rating
    99
    jerome76 is just really nice jerome76 is just really nice jerome76 is just really nice jerome76 is just really nice jerome76 is just really nice

      0  

    Default


    You could dynamically create itemId's for the buttons when creating instances of the panel, but the way you I understand what you mean.

    I know there are many ways to use Ext.ComponentQuery.query().

    You could try using:
    Code:
    // retrieve all direct children which are Ext.Panels within myCt
    var directChildPanel =Ext.ComponentQuery.query('#myCt > panel');
    And rewriting it to be something like:
    Code:
    //maybe this works where it retrieves all direct children which are Ext.Buttons within Desk.view.Case and then [1] to pick out the second button
    var button2 = Ext.ComponentQuery.query('casesPanel > button')[1];


  5. #5
    Touch Premium Member
    Join Date
    Aug 2010
    Location
    New York, NY
    Posts
    66
    Answers
    2
    Vote Rating
    0
    sandeep45 is on a distinguished road

      0  

    Default


    This doesn't work when specified in refs property.

    Quote Originally Posted by jerome76 View Post
    You could dynamically create itemId's for the buttons when creating instances of the panel, but the way you I understand what you mean.

    I know there are many ways to use Ext.ComponentQuery.query().

    You could try using:
    Code:
    // retrieve all direct children which are Ext.Panels within myCt
    var directChildPanel =Ext.ComponentQuery.query('#myCt > panel');
    And rewriting it to be something like:
    Code:
    //maybe this works where it retrieves all direct children which are Ext.Buttons within Desk.view.Case and then [1] to pick out the second button
    var button2 = Ext.ComponentQuery.query('casesPanel > button')[1];


  6. #6
    Sencha User jerome76's Avatar
    Join Date
    Apr 2012
    Location
    New Jersey
    Posts
    1,135
    Answers
    129
    Vote Rating
    99
    jerome76 is just really nice jerome76 is just really nice jerome76 is just really nice jerome76 is just really nice jerome76 is just really nice

      0  

    Default


    I'm sorry, I don't use Ext.Controllers so I couldn't have known. Maybe someone else has another idea. I suggest to continue playing around with that example for now until then.

  7. #7
    Sencha User
    Join Date
    Apr 2012
    Location
    ShenZhen, China
    Posts
    52
    Answers
    11
    Vote Rating
    2
    liaoyiwu is on a distinguished road

      1  

    Default


    give the button an 'action' property, then use refs to locate it
    Code:
    items: [{
          xtype: 'button',
          text: 'button1',
          action: 'doButton1Action'
    },{
          xtype: 'button',
          text: 'button2',
          action: 'doButton2Action'
    },...]
    Code:
    refs: {
         button2:  '
    casesPanel button[action=
    doButton2Action]' },
    control: {
    button2: { tap: 'doTapButton2' }
    }

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