PDA

View Full Version : XTemplate + Touch form controls



Bucs
28 Dec 2010, 7:22 AM
Is it safe to assume that you should never try to use XTemplate to create HTML forms in Touch? I am finding that trying to mix HTML form controls created using XTemplates is not a good idea as they do not play nice with the surrounding Touch controls and layouts. XTemplates are fantastic and powerful when it comes to consuming a nested JSON object a producing a READ-ONLY form display or template, but they do not seem to work well if you need to create a form that requires input. Touching any of the regular HTML controls will do things like scroll the whole screen, rather than just the card containing the controls, and this will do bad things like pull docked tab bars etc. off of their docked positions.

Is it possible to use XTemplates to create a mix of HTML and Touch controls? It tried very briefly to inject a control like {xtype: 'textfield'} into the middle of the XTemplate, but all I got in the output was [object]. Plus, not sure you would get any layout management whatsoever doing this.

So, am I correct in assuming that we should not use XTemplates to create HTML forms for these reasons?

Thx.

dramey
13 Sep 2011, 10:18 AM
I am having a similar problem
I need to dynamically generate a form with an unknown number of fields.
This is pretty standard behavior, and I'd like to avoid creating custom setter functions for each form I build.

Can XTemplate be used to generate forms?

Bucs
13 Sep 2011, 10:30 AM
Good luck with that. I tried my hardest to get them to understand that the XTemplate needs to be able to *easily* work with the Touch controls in order to build more complicated forms, especially when trying to mimic HTML forms already created. All I got was that I was following an "anti-pattern" by trying to get XTemplates to inject Touch controls. And the kicker is that you cannot inject regular HTML controls either as any one that accepts focus during a swipe operation will pull the viewport completely out of whack.

We ended up having to dump Touch altogether as a result of this...and they still don't appears to have any plans to provide a mechanism to allow for this. If you intend to build mobile web apps that target device that you cannot control, especially if you work in a bigger shop that starts the mobile web process off with delivering to dev the creative assets in HTML format that you then need to "redo" in the Touch way of thinking....you will soon get very frustrated. You will be much better served to go with a "progressive enhancement" option. However, if you are building internal web apps, then by all means Touch wil work great.

Good luck.

edspencer
13 Sep 2011, 6:42 PM
Rendering controls (usually based off a Store) has been requested a lot, so we've implemented it in 2.0. I don't want to give too much away right now as the beta launch is just around the corner, but suffice it to say that the number 1 use case for this functionality is now baked into the framework and used internally by it.

In 1.x, XTemplate is purely there for generating markup, not components

Bucs
13 Sep 2011, 6:48 PM
Well that is some welcomed news! Looking forward to checking out the 2.0 product and hearing about the new features.

Thanks for the update Ed.

edspencer
13 Sep 2011, 6:52 PM
You're welcome, hope we can win you back :)

dramey
14 Sep 2011, 8:54 AM
Thanks Ed,
Will this also apply to XTemplates in standard Ext JS, for example, form panels?

edspencer
14 Sep 2011, 9:55 AM
Thanks Ed,
Will this also apply to XTemplates in standard Ext JS, for example, form panels?

Possibly, but not until 5.x due to the architectural changes required. We have improved many aspects of XTemplate in 4.1 though (largely speed and legibility of generated code)