Forms isolation and components traversing

January 8th, 2009
  • This is a feature that have to do with business logic not with graphics.
    I've write of this problem at the end of this post
    http://extjs.com/forum/showthread.php?p=126765#post126765

    I think that isolation and incapsulation of Exts objects is important, that will make it easy to handle datasets.
    This thing is also related with components traversing, in some case where there isn't an easy way to find an object inside another object. Like to find parents, siblings, childrens and so on.
    The find or findById methods will often fails, or I don't understand how do they work.
    Like toolbars that do not offer any method to find buttons and elements inside of them. At least it seems so from the documentation.
    Maybe my approach is wrong but as I can load a dataset in a grid without to worry about fields names, I mean that I don't have to worry if any other grid in the page use a dataset with equal fields names, the same I would do with data loaded inside forms.
    But my tests say that with forms is necessary to use a prefix to give to any field a unique id. Otherwise if the page have 2 forms with the same fields ids is impossible to know where data will be loaded.


  • I've rewrited all forms using unique IDs for find the component with functions like findField and dataIndex (with the database field name) to load datasets from server.
    Using dataIndex forms are really isolated and do not conflict each other. Maybe you should add some explaination in the field API docs for dataIndex.That property isn't mentioned in the documentation and for me has been very important to manage this situation.


  • Two components can't have the same ID. IDs must be unique. Try using names or dataIndex if you need them to have the same "key" for loading.


  • Maybe it could be enough to add a dataIndex property to fields to handle this situation, like columnModel has.


  • All the components you mention have an "items" property which is a MixedCollection and provides access to the contained components. The Toolbar document was somehow missing it. This has been corrected.


  • Thanks for reply.
    I understand how it works, I've also read the code of BasicForm and MixedCollection, but somehow it fails.
    Also if findField iterates the items collection, if I have 2 forms in the same page where fields have the same ids, loadRecord or setValues fails to load data in the right form.
    It seems that they load data in the first field they find in the DOM that have this id/name/dataIndex. Also if I've tested it just with ids.
    They do not isolate the form from other forms. From the code I've read it seems they should operate inside the items collection with no relation with the DOM, but for some reason also other forms could be affected.

    I would like to know if someone else have experienced the same issue or there is something wrong in my code that makes it happend. Just to understand if is a bug, because from the code I've read it seems that you have designed forms to be properly isolated.







  • #If you have any other info about this subject , Please add it free.#
    Your name:
    E-mail:
    Telphone:

    Your comments:


    If you have any other info about Forms isolation and components traversing , Please add it free.