2017-09-15 4 views
0

탭에 3 개의 항목이 있으며 확장 상자와 같은 점 탐색을 표시하려고합니다. 여기 내 코드는 레이아웃 카드 표시기를 사용하여 코드를 수정했습니다. 따라서 표시기는 툴바에 탭을 추가 할 때와 동일한 카드 내용 및 표시기 기능을 카드에 사용합니다. 모든 지침하시기 바랍니다 .. 아래extjs를 사용하는 방법 탭 항목에 캐 러셀

코드

Ext.define('MyPage.view.search.CardIndicator', { 
    extend: 'Ext.Container', 
    xtype: 'layout-card-indicator', 
    controller: 'layout-card-indicator', 

    requires: [ 
     'Ext.layout.Card', 
     'Ext.tab.Panel' 
    ], 

    height: 300, 
    layout: 'fit', 
    width: 400, 

    viewModel: { 
     data: { 
      tapMode: 'direction' 
     } 
    }, 

    items: [{ 
     xtype: 'panel', 
     reference: 'panel', 
     shadow: 'true', 
     bodyPadding: 15, 

     layout: { 
      type: 'card', 
      // The controller inserts this indicator in our bbar 
      // and we publish the active index and card count 
      // so we can easily disable Next/Prev buttons. 
      indicator: { 
       reference: 'indicator', 
       bind: { 
        tapMode: '{tapMode}' 
       }, 
       publishes: [ 
        'activeIndex', 
        'count' 
       ] 
      } 
     }, 

     items: [{ 
      title:'abc', 
      html: '<h2>Welcome to the Demo Wizard!</h2><p>Step 1 of 3</p><p>Please click the "Next" button to continue...</p>' 
     }, { 
      title:'abc', 
      html: '<p>Step 2 of 3</p><p>Almost there. Please click the "Next" button to continue...</p>' 
     }, { 
      title:'abc', 
      html: '<h1>Congratulations!</h1><p>Step 3 of 3 - Complete</p>' 
     }], 

     bbar: { 
      reference: 'bbar', 
      items: [ 
      { 
       text: '&laquo; Previous', 
       handler: 'onPrevious', 
       bind: { 
        disabled: '{!indicator.activeIndex}' 
       } 
      }, 
      // the indicator is inserted here 
      { 
       text: 'Next &raquo;', 
       handler: 'onNext', 
       bind: { 
        disabled: '{indicator.activeIndex == indicator.count - 1}' 
       } 
      } 
      ] 
     } 
    }, 
    { 
     xtype: 'toolbar', 
     docked: 'top', 
     ui: 'transparent', 
     padding: '5 8', 
     layout: 'hbox', 

     defaults: { 
      shadow: 'true', 
      ui: 'action' 
     }, 

     items: [{ 
      xtype: 'tabpanel', 
      // bind: '{tapMode}', 

      tabBar: { 
     docked: 'top', 
     scrollable: 'horizontal', 
     height:'44px', 
     cls:'tabbuttons', 
    }, 

    items: [ 
    { 
     title: 'Tab 1' 
    }, { 
     title: 'Tab 2' 
    }, { 
     title: 'Tab 3' 
    } 
    ], 
     }] 
    } 
    ] 
}); 

컨트롤러

Ext.define('MyPage.view.search.CardIndicatorController', { 
    extend: 'Ext.app.ViewController', 
    alias: 'controller.layout-card-indicator', 

    init: function (tabspanel, value, oldValue) { 
     var bbar = this.lookup('bbar'); 
     var card = this.lookup('panel').getLayout(); 

     // Lazily create the Indicator (wired to the card layout) 
     var indicator = card.getIndicator(); 

     // Render it into our bottom toolbar (bbar) 
     bbar.insert(1, indicator); 
     var tabs = tabspanel.config.items; 

     console.log(tabs); 

    }, 

    onNext: function() { 
     var card = this.lookup('panel').getLayout(); 

     card.next(); 
    }, 

    onPrevious: function() { 
     var card = this.lookup('panel').getLayout(); 

     card.previous(); 
    } 
}); 
+0

** ** 회전 목마가없는 *이 바닥 표시와 탭에 대한 뷰를 생성하는 데 도움이됩니다 내 대답을 공유 *. 이를 위해 요구 사항에 따라 사용자 지정 구성 요소를 만들어야합니다. [예] (https://github.com/parham-fazel/extjs-carousel) –

+0

감사합니다. @ Njdhv 지금 카드와 탭에 대해 동일한 항목을 사용하려고하는데 코드를 수정했습니다.이 부분을 살펴 보시기 바랍니다. 내가 이것을 현대에만 사용하고 있기 때문에. – Sagar

+0

** ** 현대 **를 원한다면 [ExtJs Docs] (https://docs.sencha.com/extjs/6.5.1/modern/Ext.carousel.Carousel.html)를 참조하십시오. 현대 –

답변

0

수정이 사용하는 카드 지수 및 탭 인덱스 변경 방법입니다.

// 카드의 변화에 ​​**의 ExtJS 고전에서

cardindexchange: function(panel, value, oldValue) { 
    var activeCard = Ext.getCmp('cards').getActiveItem(); 
    activeIndex = Ext.getCmp('cards').indexOf(activeCard); 
    Ext.getCmp('tabs').setActiveItem(activeIndex); 

},