EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: MSAG on January 12, 2019, 07:39:34 AM



Title: [Solved]Reorder Tabs from Code
Post by: MSAG on January 12, 2019, 07:39:34 AM
Hi
As doc of insert tab in special location we must use index to set like this:

// add a unselected tab panel
$('#tt').tabs('add',{
   title: 'new tab',
   selected: false
   //...
});

// insert a tab panel to the index 2
$('#tt').tabs('add',{
   title: 'inserted tab',
   index: 2
})


but what about if we just want to reorder old tab without lose content of its

i tried to use update like this:

oldtab.panel("options").index =newIndex;
$('#tt').tabs('update', { tab: oldtab, index: newIndex, options: oldtab.panel("options"), type: "header" });


but that is not work

and then i tried to add more this code:

$(oldtab.panel('options').tab).parent().append(oldtab.panel('options').tab);

it is work to move tab to first location

and i use it to push all tabs as i wont

my problem is:
when i click on tabs it go to panel of old tab index (show me the panel for old index not the new)

how can i fix it

thanks a lot


Title: Re: Reorder Tabs from Code
Post by: MSAG on January 13, 2019, 10:11:45 AM
Full my code of update to reorder tabs:


here code of sort my list LLogindTabInfo
then:


            for (i = 0; i < LLogindTabInfo.length; i++) {
                        if (dg.tabs('exists', LLogindTabInfo.Title)) {
                            var tab = dg.tabs('getTab', LLogindTabInfo.Title);
                            if (!tab.panel('options').href)
                                dg.tabs('update', { tab: tab, index: i, options: { href: LLogindTabInfo.Url } });
                            else {
                                tab.panel('options').index = i;
                                dg.tabs('update', { tab: tab, index: i, options: tab.panel("options"), type: "header" });
                            }
                        }
                        tab.panel('options').index = i;
                        $(tab.panel('options').tab).parent().append(tab.panel('options').tab);
                    }


Title: Re: Reorder Tabs from Code
Post by: stworthy on January 14, 2019, 06:07:22 PM
The 'move' method is available from the tabs extension https://www.jeasyui.com/extension/downloads/tabs-dnd.zip. Call the 'move' method to reorder the tab panels.
Code:
var tab = $('#tt').tabs('getSelected');
$('#tt').tabs('move', {
tab: tab,
index: 2
})


Title: Re: [Solved]Reorder Tabs from Code
Post by: MSAG on January 14, 2019, 07:37:57 PM
It's work thank you very much Mr. stworthy ;D ;D ;D ;D ;)