[CLOSED] TabPanel : Reopen tab

  1. #1

    [CLOSED] TabPanel : Reopen tab

    I have 2 tabs inside tab panel ,I want on button click Tab 2 reopen (Close then open again) how do I do.
    @(X.TabPanel()
     .ID("t")
                
            .Items
            (
                X.Panel()
                .Title("Tab 1")
                .ID("t1")
                ,
                 X.Panel()
                .Title("Tab 2")
                .ID("t2")
                .Closable(true)
            ))
            @(X.Button()
                .Text("Click")
                        .Listeners(l => {
                            l.Click.Handler = ""; 
                        })
                
                )
    Last edited by Daniil; Feb 17, 2015 at 11:39 AM. Reason: [CLOSED]
  2. #2
    Hello matrixwebtech,

    Please do you best to put together as much of the sample as you can and then post your sample here.

    There are lots of code snippets in the forums demonstrating how to open (or show) a Panel. Start with one of those samples and build from there.

    If you run into a specific problem that you cannot solve, we would be happy to help.
    Geoffrey McGill
    Founder
  3. #3
    @{
        var X = Html.X();
        Layout = null;
    }
    
    <!DOCTYPE html>
    
    <html>
    <head>
        <meta name="viewport" content="width=device-width" />
        <title>Index</title>
    
        @(X.XScript().ScriptBlock(@"
            <script>
                var addTab = function (tabPanel, id, url) {
                    var tab = tabPanel.getComponent(id);
    
                    if (!tab) {
                        tab = tabPanel.add({
                            id       : id,
                            title    : url,
                            closable : true,
                         
                            loader   : {
                                url      : url,
                                renderer : 'frame',
                                loadMask : {
                                    showMask : true,
                                    msg      : 'Loading ' + url + '...'
                                }
                            }
                        });
    
                      
                    }
               
                    tabPanel.setActiveTab(tab);
                }
            </script>"
        ))
    
    </head>
    <body>
        <div>
            @X.ResourceManager()
            @(X.TabPanel()
                .ID("t")
               
            .Items
            (
                X.Panel()
                .Title("Tab 1")
                .ID("t1")
                ,
                 X.Panel()
                .Title("Tab 2")
                .ID("t2")
                .Closable(true)
            ))
            @(X.Button()
                .Text("Click")
                        .Listeners(l => {
                            l.Click.Handler = @"App.t.closeTab(App.t2)
                                                addTab(App.t,'t2','http://www.example.com')
                                                ";
                        })
               
                )
        </div>
    </body>
    </html>
    I try above code.and its working fine.is this need any tuneup?
  4. #4
    Hi @matrixwebtech,

    If it works as you need, then it is good enough.

    It looks the only thing I would do is getting rid of
    @(X.XScript().ScriptBlock(@" ...
    and using just
    <script>
        var addTab = function (tabPanel, id, url) {
            ...
        }
    </script>

Similar Threads

  1. [CLOSED] AllowBlank="false" problem when reopen the window
    By hdsoso in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: May 08, 2013, 11:30 AM
  2. [CLOSED] Updating content in tabpanel causes tabpanel to redraw incorectly
    By taylorjp2000 in forum 1.x Legacy Premium Help
    Replies: 9
    Last Post: Sep 26, 2012, 2:06 PM
  3. Replies: 1
    Last Post: May 08, 2012, 8:21 AM
  4. Replies: 3
    Last Post: Aug 21, 2009, 2:24 PM
  5. Reopen tab after closing
    By methode in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Dec 01, 2008, 1:35 PM

Posting Permissions