1. #1
    Sencha User
    Join Date
    Jul 2009
    Posts
    47
    Vote Rating
    0
    navi75 is on a distinguished road

      0  

    Default ContentPanel do not show on click of button

    ContentPanel do not show on click of button


    I am using EXT-GWT2.01 and GWT1.7 and added two contentPanel into a HorizontalPanel.

    ContentPanel one = new ContentPanel();
    one.add(new Grid());

    ContentPanel two = new ContentPanel();
    two.add(new LabelField("text"));
    two.hide();

    HorizontalPanel hp = new HorizontalPanel();
    hp.add(one);
    hp.add(two);

    Since i have hide the second contentPanel inorder to show only the first contentPanel initially.

    Now on the click of the button on the toolbar, i want to hide the first contentPanel and show the second contentPanel which was hidden earlier.

    on the click of the toggleButton

    if(contentPanelone.isVisible()) {
    one.hide();
    two.show();
    }

    The problem is that the one contentPanel does hide but it did not show the second contentPanel on the call for two.show();

    Can anyone help me on the same?

  2. #2
    Ext User
    Join Date
    Sep 2008
    Location
    Germany
    Posts
    961
    Vote Rating
    0
    Arno.Nyhm is on a distinguished road

      0  

    Default


    i think you should provide a full working example which shows your error. i think is on other place in your code.

    i try your situation and it works fine:

    PHP Code:
    package org.yournamehere.client.forum.code.snippets;

    import com.extjs.gxt.ui.client.event.ButtonEvent;
    import com.extjs.gxt.ui.client.event.SelectionListener;
    import com.extjs.gxt.ui.client.widget.ContentPanel;
    import com.extjs.gxt.ui.client.widget.HorizontalPanel;
    import com.extjs.gxt.ui.client.widget.button.Button;
    import com.extjs.gxt.ui.client.widget.form.LabelField;
    import com.google.gwt.core.client.EntryPoint;
    import com.google.gwt.user.client.ui.RootPanel;

    public class 
    ForumThread367150 implements EntryPoint {

        public 
    void onModuleLoad() {
            final 
    ContentPanel one = new ContentPanel();
            
    one.add(new LabelField("text one"));

            final 
    ContentPanel two = new ContentPanel();
            
    two.add(new LabelField("text two"));
            
    two.hide();

            
    HorizontalPanel hp = new HorizontalPanel();
            
    hp.add(one);
            
    hp.add(two);
            
    hp.add(new Button("click me", new SelectionListener<ButtonEvent>() {

                @
    Override
                
    public void componentSelected(ButtonEvent ce) {

    //                if (one.isVisible()) {
    //                    one.hide();
    //                    two.show();
    //                } else {
    //                    one.show();
    //                    two.hide();
    //                }

                    
    boolean isVisible one.isVisible();
                    
    one.setVisible(!isVisible);
                    
    two.setVisible(isVisible);
                }
            }));

            
    RootPanel.get().add(hp);
        }


  3. #3
    Sencha User
    Join Date
    Jul 2009
    Posts
    47
    Vote Rating
    0
    navi75 is on a distinguished road

      0  

    Default


    Thanks for your response.

    I have solved the issue with the help of Registry.set(obj) in the onModuleLoad and Registry.get(obj) to retrieve the main object which has all of the contentpanel objects and once i retrieve the main object with the help of Registry, i used getItemByItemId("Id") to retrieve the contentpanel object and then used the hide and show functions on the same.

  4. #4
    Ext User
    Join Date
    Sep 2008
    Location
    Germany
    Posts
    961
    Vote Rating
    0
    Arno.Nyhm is on a distinguished road

      0  

    Default


    fine that you solve your issue.

    but what im not understand why you need the Registry things. what is special with your case? can you give some example code.

  5. #5
    Sencha User
    Join Date
    Jul 2009
    Posts
    47
    Vote Rating
    0
    navi75 is on a distinguished road

      0  

    Default


    I used Registry to get the reference of the first contentpanel object which i need to hide and show the second content panel.

  6. #6
    Ext User
    Join Date
    Sep 2008
    Location
    Germany
    Posts
    961
    Vote Rating
    0
    Arno.Nyhm is on a distinguished road

      0  

    Default


    so the problem was not that you can not hide the panels - so it was more the problem that you dont have a reference to this panel?
    This forum needs your help: you got hints from the community and now you have fixed your code? dont just reply with "now its fixed" or "i found the error"! please take the time to post also an detailed answer with the working code.

    GreaseMonkey Script for a GXT-only Forum: it hides ExtJs here: New Posts • Search Results • Advanced Search form • Category overview http://www.extjs.com/forum/showthrea...041#post410041

  7. #7
    Sencha User
    Join Date
    Jul 2009
    Posts
    47
    Vote Rating
    0
    navi75 is on a distinguished road

      0  

    Default


    Yes. The problem was How to get the reference of the two contentpanel objects.

    Thanks.

Thread Participants: 1