PDA

View Full Version : Best Way to load data for a form



Urkman
2 Dec 2009, 10:39 PM
Hello,

I display my forms in a window.
When I display a window containing a form I would like to load the data for this form.
What is the best way to do this? I can't use onRender(), because when i display the form a secound time, the form is not rendered then...

Thanks for your Help,
Urkman

CrazyEnigma
3 Dec 2009, 7:24 AM
<your form>.getForm().setValues(<your data object>);


If your form inputs have a name property, setValues will map the values from the object.

Urkman
4 Dec 2009, 3:18 AM
Hello CrazyEnigma,

thanks for your answer, but this was not what I was looking for. I think my question was wrong:
I'm looking for "when" not "how" I load the data into my form...

What is the best event to listen to and what is the best way to implement the listener?

I tried the "show"-event, but it never get's fired. But perhaps I'm doing something wrong...

Thanks,
Urkman

Animal
4 Dec 2009, 3:32 AM
The event will get fired if the form is shown and hidden.

But its up to you . When do you want to load it???

CrazyEnigma
4 Dec 2009, 12:55 PM
Post your show event code. Are you showing the window and hiding it or destroying the window each time?

The show event should fire, but maybe you are losing scope.

Mike Robinson
4 Dec 2009, 3:10 PM
Basically, just before you show your form, you need to load the data into it. Then, when the "OK" button is pressed, you put it back.

Didn't take me long to spin-off a base class to do this.