PDA

View Full Version : how to properly extend, clone, array, define, create, copy, duplicate, add, remove



i_outrun_my_scripts
2 Feb 2014, 3:06 PM
I do not know which term accurately describes what I'm trying to do, these are the keywords my internet searches yielded for the behavior I'm trying to get: extend, clone, array, define, create, copy, duplicate, add/remove

The behavior I'm trying to get is to be able to generically add/remove (with a unique id) each control in my form.

By "control in my form", I mean a dropdown list, or a date field, or a text field, or an entire fieldset, rows in a table/grid, or even an entire form section (containing several field sets).

My form idea is a dynamic one - allowing the form filler to add/remove sections based on his needs. This is for a technical jobsite inspection application where form-filler judgement calls are necessary. Hiding/showing elements will not be viable, since on one day a form-filler may need 100 clones of one control, and the next day 0 of them.

From searching the internet, there appears to be a myriad of ways to do this, however I am trying to understand the most stable and flexible way, or why you should use x way for x scenario or y way for y scenario if there is not a one-size-fits-all solution.Here is a blogpost showing similar behavior to what I want: http://ext4all.com/post/dynamic-fieldset-add-remove.html

However, in this thread: http://www.sencha.com/forum/showthread.php?188498

there is a sencha user named mitchellsimoens who says that the above solution "shouldn't use Ext.define within Ext.onready" but I couldn't deduce why this is.

From the internet on an unrelated train of thought, I found this: https://github.com/pvorb/node-clone

It appears to be a way to deep-clone a variety of javascript elements which sounds like a good solution, but I'm very new to javascript and I'm not sure if you can integrate this external code into ext js 4?

In summary, I'm just in research mode trying to identify what I need to do, and how best to do it.

mitchellsimoens
6 Feb 2014, 12:54 PM
So all you are trying to do is add and remove form fields from the form?