1. #1
    Sencha User arpeggian's Avatar
    Join Date
    Dec 2011
    Posts
    21
    Vote Rating
    1
    arpeggian is on a distinguished road

      0  

    Default Unanswered: Id conflicts in multiple tabs

    Unanswered: Id conflicts in multiple tabs


    Dear all

    I'm building extjs-based applications. My application has many links in the navigation, and every link clicked will create a new tab in contentPanel. this my tree listener code:
    Code:
    url = sharedData.rootDir + data.url +'?id='+node.getId();
    if (node.isLeaf()) {
      var tab = contentPanel.add({
       // we use the tabs.items property to get the length of current items/tabs
      title: node.get('text'),
      id: node.getId(),
      closable: true,
      forceFit:true,
      autoScroll: true,
      layout:'fit',
      autoLoad: {                        
        //url: sharedData.rootDir + "app/gallery/galleryFoto.php",
         url: url,
         scripts: true,
         listeners: {
                        beforeload: function(){ viewport.setLoading(); },
                        load: function(){ 
                                            viewport.setLoading(false);
                         },
                          exception: function(){
                                              Ext.Msg.alert('Error','Halaman yang anda maksud tidak ada');
                                                                viewport.setLoading(false);
                            }
           }
        },
        listener: {
                       activate: function(){
                       alert('activate');
                       contentPanel.items.each(function(c){c.disable(); alert(c.getId());})
                                                        },
                                                        focus: function(){
                                                            alert('focus');
                                                            contentPanel.items.each(function(c){c.disable(); alert(c.getId());})
                                                        }
                                                    }
                                                });
    if(tab)
      contentPanel.setActiveTab(tab);
    contentPanel.items.each(function(c){ if (c.getId() != tab.getId()) c.query('input').disable(); })
    }
    }
                                        
    },
    The problem is, when a single tab (A) there is a component with id: 'MyField' and in another tab ( there is also a component with the same id, the id: 'MyField' .. then there is the field 'MyField' in tab A will disappear, and the layout or arrangement of B field in the tab would be a mess.


    if there is no other way than to use a unique id for each component, although different tab. or any other means, such as adding listeners when ditambahakan tab, then the other tab is disabled? or multiple fields / components is disabled?


    please help me .. sorry for my bad english. thank you


    regards

  2. #2
    Touch Premium Member
    Join Date
    Jun 2011
    Posts
    1,099
    Vote Rating
    96
    Answers
    113
    Farish is a glorious beacon of light Farish is a glorious beacon of light Farish is a glorious beacon of light Farish is a glorious beacon of light Farish is a glorious beacon of light

      0  

    Default


    Instead of id, use itemId (check out the API Docs for details)

  3. #3
    Sencha User arpeggian's Avatar
    Join Date
    Dec 2011
    Posts
    21
    Vote Rating
    1
    arpeggian is on a distinguished road

      0  

    Default


    Quote Originally Posted by Farish View Post
    Instead of id, use itemId (check out the API Docs for details)
    thanks for the reply. if itemid will not conflict? ok, there is a statement of the itemid is scoped locally to the container ... itemid if I can use to store the identifier of? for example, there is a grid, form, store .. (crud) .. if I can use to perform loadRecord itemid from store?


    thank you Farish.

  4. #4
    Ext JS Premium Member
    Join Date
    Jan 2010
    Location
    San Diego, CA
    Posts
    254
    Vote Rating
    5
    Answers
    5
    dbrin is on a distinguished road

      0  

    Default


    Or don't use IDs at all and use ComponentQuery to target your components. You can set any arbitrary property and use query/up/down methods passing in [property=value] identifiers of your components.

  5. #5
    Sencha User arpeggian's Avatar
    Join Date
    Dec 2011
    Posts
    21
    Vote Rating
    1
    arpeggian is on a distinguished road

      0  

    Default


    Quote Originally Posted by dbrin View Post
    Or don't use IDs at all and use ComponentQuery to target your components. You can set any arbitrary property and use query/up/down methods passing in [property=value] identifiers of your components.
    thanks for the replies,


    attractive solution, but if in that way I will lose loadRecord from store to feature my form? id identifies the default?

  6. #6
    Ext JS Premium Member
    Join Date
    Jan 2010
    Location
    San Diego, CA
    Posts
    254
    Vote Rating
    5
    Answers
    5
    dbrin is on a distinguished road

      0  

    Default


    not really, you don't loose anything you just do things a little differently. you still need to identify records. So record ID is ok - just don't use it to set other component's IDs.

Thread Participants: 2

Tags for this Thread