Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Ext JS Premium Member KimSchneider's Avatar
    Join Date
    Jul 2008
    Location
    Germany
    Posts
    68
    Vote Rating
    0
    KimSchneider is on a distinguished road

      0  

    Default [DUPE-949] CompositeField and Form.find

    [DUPE-949] CompositeField and Form.find


    Hi,

    I don't know if this is a bug or just my fault.

    If I put a textfield into a compositefield and run form.find on the name of the textfield, I get no results. The Api says "Find a component under this container at any level by property"...

    Example:

    Code:
    var form = new Ext.form.FormPanel({
                items : [{ 
                    xtype : 'compositefield',
                    items : [{
                        xtype : 'textfield',
                        name: 'city',
                        flex : 1
                    }]
                }]
            });
            
            form.find('name', 'city');
    This returns an empty array...Any solution for this?
    Kim Schneider
    Lead Developer

    Server-Eye
    Alte Koßmannschule
    Koßmannstraße 7
    66571 Eppelborn
    Germany

    Email: kim.schneider@server-eye.de
    Homepage: www.server-eye.de

    Do you know our revolution in network- and servermonitoring?
    www.server-eye.de

  2. #2
    Sencha Premium Member tobiu's Avatar
    Join Date
    May 2007
    Location
    Munich (Germany)
    Posts
    2,695
    Vote Rating
    114
    tobiu is a name known to all tobiu is a name known to all tobiu is a name known to all tobiu is a name known to all tobiu is a name known to all tobiu is a name known to all

      0  

    Default


    try out:
    Code:
    form.getForm().findField('city');

    kind regards,
    tobiu
    Best regards
    Tobias Uhlig
    __________

    S-CIRCLES Social Network Engine

  3. #3

  4. #4
    Sencha - Services Team Stju's Avatar
    Join Date
    Dec 2008
    Location
    Redwood city, California
    Posts
    290
    Vote Rating
    3
    Stju is on a distinguished road

      0  

    Default


    Try this override:
    Code:
    //Override for finding fields in composite, checkboxgroups or radiogroups
    Ext.override(Ext.BasicForm, {
      findField: function(id) {
            var field = this.items.get(id);
    
            if (!Ext.isObject(field)) {
                //searches for the field corresponding to the given id. Used recursively for composite fields
                var findMatchingField = function(f) {
                    if (f.isFormField) {
                        if (f.dataIndex == id || f.id == id || f.getName() == id) {
                            field = f;
                            return false;
                        } else if (f.isComposite && f.rendered) {
                            return f.items.each(findMatchingField);
                        } else if (f.isRadioGroup && f.rendered) {
                            return f.items.each(findMatchingField);
                        } else if (f.isCheckboxGroup && f.rendered) {
                            return f.items.each(findMatchingField);
                        }
                    }
                };
                this.items.each(findMatchingField);
            }
            return field || null;
        }
    });
    Last edited by Stju; 8 Jul 2010 at 3:27 PM. Reason: added comments

  5. #5
    Ext JS Premium Member KimSchneider's Avatar
    Join Date
    Jul 2008
    Location
    Germany
    Posts
    68
    Vote Rating
    0
    KimSchneider is on a distinguished road

      0  

    Default


    Thanks for your replies.

    As I dont like overrides, will work with

    Code:
    form.getForm().findField('city');
    Kim Schneider
    Lead Developer

    Server-Eye
    Alte Koßmannschule
    Koßmannstraße 7
    66571 Eppelborn
    Germany

    Email: kim.schneider@server-eye.de
    Homepage: www.server-eye.de

    Do you know our revolution in network- and servermonitoring?
    www.server-eye.de

  6. #6
    Sencha - Services Team Stju's Avatar
    Join Date
    Dec 2008
    Location
    Redwood city, California
    Posts
    290
    Vote Rating
    3
    Stju is on a distinguished road

      0  

    Default


    @Kim Schneider

    Sure, You can patch original code without override
    As bugreport 949 states there is problem with composite fields, so form.getForm().findField('city') in your case won't work.
    The same applies when You want to load data in form with composite fields and radio/checkbox groups. They won't be loaded without this patch (as of version 3.2.2) as original version of findField look only on first level and don't go deeper

  7. #7
    Ext JS Premium Member KimSchneider's Avatar
    Join Date
    Jul 2008
    Location
    Germany
    Posts
    68
    Vote Rating
    0
    KimSchneider is on a distinguished road

      0  

    Default


    Hm, strange...I'm using

    Code:
    form.getForm().loadRecord
    and

    Code:
    form.getForm().findField
    AFTER the form is rendered and displayed to the user and both works perfect with composite fields.
    Kim Schneider
    Lead Developer

    Server-Eye
    Alte Koßmannschule
    Koßmannstraße 7
    66571 Eppelborn
    Germany

    Email: kim.schneider@server-eye.de
    Homepage: www.server-eye.de

    Do you know our revolution in network- and servermonitoring?
    www.server-eye.de

Similar Threads

  1. Replies: 14
    Last Post: 14 Jan 2011, 6:24 AM
  2. Replies: 7
    Last Post: 20 Jul 2010, 1:19 AM
  3. CompositeField and Form.find
    By KimSchneider in forum Ext 3.x: Help & Discussion
    Replies: 0
    Last Post: 6 Jul 2010, 11:26 PM
  4. Replies: 3
    Last Post: 3 Jun 2010, 5:33 AM
  5. Load form on 'render' event but CompositeField not rendered yet.
    By jarlau in forum Ext 3.x: Help & Discussion
    Replies: 2
    Last Post: 9 Apr 2010, 1:45 AM

Thread Participants: 3