1. #1
    Sencha User
    Join Date
    Nov 2010
    Posts
    85
    Vote Rating
    1
    KallDrexx is on a distinguished road

      0  

    Default How do I find out when a FormPanel's form is accessible with getForm().getValues()?

    How do I find out when a FormPanel's form is accessible with getForm().getValues()?


    I have a panel that I am adding to my main TabPanel. The panel I am adding contains a FormPanel as one of it's items and inside the FormPanel I have a Name field. What I want to do is change the name of the Tab based on the name in the form field.

    The problem is that if I call the FormPanel's getForm().getValues() inside of the panel's initComponent, I get the following javascript error:

    Uncaught TypeError: Cannot read property 'dom' of undefined

    If I do this outside of initComponent (e.g. on a button press) everything works fine. After doing some testing, I think the issue is that the FormPanel isn't actually rendered yet (and thus the dom doesn't exist), getValues() fails. However, I can't seem to figure out a way to get my FormPanel's values from the Panel on load.

    I tried to listen for events. I tried:

    Code:
    this.detailForm.on('afterrender', function () { alert('test'); });
    but doing this showed that AfterRender is called prior to the form actually being rendered (it's not visible on the screen). Changing the alert to my custom function handler produces the previous dom exception. I attempted to use the 'activate' and 'enable' events instead of 'afterrender', but even though the API says that FormPanel fires those events, the alert('test') never gets called.

    I can't seem to find any way for my panel to get the inner FormPanel's values upon loading my panel. Does anyone have any ideas?

  2. #2
    Sencha - Community Support Team jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    DC Area =)
    Posts
    16,364
    Vote Rating
    81
    jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all

      0  

    Default


    my question is why do you need the form's values BEFORE its rendered?

  3. #3
    Sencha User
    Join Date
    Nov 2010
    Posts
    85
    Vote Rating
    1
    KallDrexx is on a distinguished road

      0  

    Default


    Upon loading the outer panel (Let's call it my TabPanel), I need to immediately load the inner FormPanel's data. So in my TabPanel's initcomponent, I call my loadData function of my FormPanel. However, once that data is loaded I need my TabPanel's title to change to reflect the FormPanel's "Name" field (so the tab's title actually relates to the object it's for. Since the FormPanel's loadData is called in the TabPanel's initComponent, the FormPanel hasn't been rendered yet when data is loaded and thus getValues() fails. Therefore, I needed soem way to automatically retrieve the form's data as soon as it is available so my tab can update it's title.

    I have actually fixed this by changing my form's base class (based off of your book actually) to getFieldValues() instead of getValues(), as this seems to work and doesn't seem to be dom/rendered dependent. Another solution was to add a listener for the form's 'afterLayout' event, but I chose to use getFieldValues() because it felt like a better solution to me.

    As an FYI, I am using an inner formpanel (instead of making the whole tab a formpanel) because the FormPanel will be different depending on the type of object the user is modifying. However, every form panel I will be adding to the tab will always have a Name field.

    And sorry about the double post. I was confused because this post wasn't showing up even though other questions I asked before and after.
    Last edited by KallDrexx; 10 Dec 2010 at 8:16 AM. Reason: grammar

Similar Threads

  1. Replies: 1
    Last Post: 10 Dec 2010, 7:52 AM
  2. Replies: 6
    Last Post: 20 Apr 2009, 8:11 PM
  3. Replies: 4
    Last Post: 10 Feb 2009, 8:26 AM
  4. Replies: 2
    Last Post: 14 Mar 2008, 1:54 AM

Thread Participants: 1