How do you go about creating ExtJS components on the fly?
I have been working on a reports viewer web application that uses ExtJS. Its main goal is to allow users to type in or select values for the parameters of any report available, run the report and view the results.
For this application, the available reports are not known beforehand, and one of the challenges I am facing is the fact that the user interface elements that will allow users to enter values for the report parameters need to be created and added to their containers on the fly, upon reading a report definition file for the report selected by the user.
Here is a simplified version of the approach I am taking. Even though I am not an ExtJS expert, I am presenting it hoping that it will help some of you.
First, I created a few helper functions that build the different UI elements I am going to need, combo boxes, radio groups, checkbox groups, etc.
And then I wrote a function that, called once a report definition has been retrieved from the server, will dynamically compose the required user interface elements and add them to their container.
I hope this is useful. Please let me know about the approaches you use. I am sure that, like with any other software topic, there are many ways to tackle the challenge presented here.
Download the full sample: ExtJsDynControls.zip