1. #1
    Ext User
    Join Date
    Oct 2007
    Posts
    17
    Vote Rating
    0
    wtfowned is on a distinguished road

      0  

    Default component ownerCt property always undefined ..

    component ownerCt property always undefined ..


    Im killing my brain already for 3 hours just for getting component's parent element .
    So imagine that there is panel .
    1) Then its getting updated through ajax with text and span elements .
    2) Every span element gets click event :
    Code:
           var spans = Ext.query("#center span"); 
           for(var i=0; i<spans.length; i++) {
              Ext.EventManager.addListener(spans[i], 'click', handle_span_click);
           }
    3)After click event get fired, im creating input field(applying it to related span - target) and combobox component(applyed to this input)

    So the problem is - how can i get parent element ( it should be span element ) of combobox, after it's select event is fired ?
    Code:
          var handle_select_change = function handle_select_change(cmb, rcd, inx) {
             alert(cmb.ownerCt); <-- undefined
          };
    Can anyone gimme some help with this ?
    The main thing that i want is to replace this combobox with selected value in span element, where its rendered to .
    Also is there any way to get input field , that combobox applyed to ?

    Hope on your answers

  2. #2
    Sencha Premium Member dawesi's Avatar
    Join Date
    Mar 2007
    Location
    Melbourne, Australia (aka GMT+10)
    Posts
    1,083
    Vote Rating
    44
    dawesi has a spectacular aura about dawesi has a spectacular aura about

      0  

    Default


    why don't you just hide the combobox and show a span with the value from the combobox in it?
    Teahouse Training Company
    Official Certified Sencha Trainer

    Australia / New Zealand / Singapore / Hong Kong & APAC



    SenchaWorld.com - Sencha webinars, videos, etc
    SenchaForge.org - (coming soon)
    TeahouseHQ.com - Sencha ecosystem training portal

    Code Validation : JSLint | JSONLint | JSONPLint

  3. #3
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    17,164
    Vote Rating
    674
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    Are you inserting the combo box into any Ext container? If you're just rendering/applying it to a page, it won't have an Ext container.

    If you want to get the parent ELEMENT:

    Code:
    var p = cmb.getEl().parent();
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  4. #4
    Ext User
    Join Date
    Oct 2007
    Posts
    17
    Vote Rating
    0
    wtfowned is on a distinguished road

      0  

    Default


    Quote Originally Posted by dawesi View Post
    why don't you just hide the combobox and show a span with the value from the combobox in it?
    In order to show span - i need to get its link first ;-)

    evant,
    Thx! Thats exactly what i was looking for .
    ------------------------------------------------------------
    And i have last , but also important problem , about combobox and floating .
    So imagine returning data :
    Code:
     a b c <span>d</span> e
      f  <span>g</span> h"
    After im rendering combobox to this span, result become :
    Code:
      a b c e
       <span><combobox>d</combobox></span> f h
       <span><combobox>g</combobox></span>"
    I cant understand, why combobox make position to change, as its parent span is "inline" ? Whats the problem? ((

  5. #5
    Ext User
    Join Date
    Oct 2007
    Posts
    17
    Vote Rating
    0
    wtfowned is on a distinguished road

      0  

    Default


    UP!

  6. #6
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    17,164
    Vote Rating
    674
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    How are we supposed to know? You haven't posted the relevant code.
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  7. #7
    Ext User
    Join Date
    Oct 2007
    Posts
    17
    Vote Rating
    0
    wtfowned is on a distinguished road

      0  

    Default


    Quote Originally Posted by evant View Post
    How are we supposed to know? You haven't posted the relevant code.
    Ok, sorry . But i think its not code's problem .

    Code:
                  // Success action form response
                   success: function(form, action){
                      var response_obj = Ext.util.JSON.decode(action.response.responseText); 
                      document.getElementById('center').innerHTML = response_obj.response_article.article; // its text + spans
                      var spans = Ext.query("#center span");
                      for(var i=0; i<spans.length; i++) {
                          Ext.EventManager.addListener(spans[i], 'click', handle_span_click);
                          Ext.DomHelper.applyStyles(spans[i], 'background-color: #90ded2;');
                      }
                      
                      Ext.getCmp('center_panel').body.highlight('#c3daf9', {block: true});
                   }
                });
    So here i got reponse with text and spans , they are showed inline, everything ok .
    So now i have like this:
    "word1 word2 <span>word3</span> word4
    word5 <span>word6</span> word7" .

    Code:
       // handle span click event function 
       var handle_span_click = function handle_span_click(ev, target) {
            if(target.getElementsByTagName('input').length < 1) {
            
               // here im making store, dont show
    
               prev_value = target.innerHTML;
               target.innerHTML = '';
    
               var input = new Ext.Element(document.createElement('input'));
               input.appendTo(target);
                
               var combo = new Ext.form.ComboBox({
                    store: store,
                    displayField: 'syns',
                    typeAhead: true,
                    mode: 'local',
                    triggerAction: 'all',
                    value: prev_value,
                    selectOnFocus:true,
                    applyTo: input,
                    listeners: {
                        select: handle_select_change
                    }
               });
            }
       };
    So now if you click span - combobox appear .
    But now data , that i showed before, will look like:

    "word1 word2 word4
    <span>word3</span> word5 word7
    <span>word6</span> " .

    And i cant understand, why do they float left .
    All i need is : 1) appear combobox normally, as span 2) after select event got fired - delete combobox and update span with selected value ( and also save all markup .. )

    Thx

Thread Participants: 2