0

Sencha Touch 2 有一个小问题:

我的应用有 2 个视图/列表:新闻和事件。两者都有详细视图。在新闻列表中,我显示了过滤器和排序按钮,在事件列表中,我只想显示过滤器按钮。

当我点击一个项目时,导航控制器会自动添加一个后退按钮。

我所做的 atm 是: - 当用户单击列表中的项目时:隐藏所有按钮 - 当用户单击后退按钮时:显示所有按钮

这就是问题所在......我看不出它是新闻详细视图还是事件详细视图上的后退按钮。

在我的控制器中,我有:

"mainnav[id=mainNav]": {
            back: 'showButtons',
        },

当我尝试时:

"panel[id=newsDetail]": {
            back: 'showButtons',
        },

事件不会被触发。那么我怎么知道它是新闻还是事件后退按钮?

谢谢!

编辑:它不容易解释......这里有更多信息:“mainNav”是一个导航视图,后退按钮被添加到它的工具栏。

Ext.define('MyApp.view.MainNav', {
extend: 'Ext.navigation.View',
alias: 'widget.mainnav',
config: {
    id: 'mainNav',
    maxWidth: '350px',
    items: [
    {
        xtype: 'tabpanel',
        layout : {
            type : 'card'
       },
...
 items: [
       {
        xtype: 'list',
        title: 'News',
        id: 'newsList',
        store: 'newsStore',
        grouped: true,
        onItemDisclosure: true,
...
    {
    xtype: 'list',
    title: 'Events',
    iconCls: 'team',
    id: 'eventList',
    store: 'eventStore',
    onItemDisclosure: true,
...
     tabBar: {
    docked: 'bottom'
}
...
and the navigation bar with its buttons:

navigationBar: {
minWidth: '',
width: '',
id: 'navBar',
layout: {
    align: 'center',
    type: 'hbox'
},
items: [
{
    xtype: 'button',
    id: 'settingsButton',
    align: 'left',
    iconCls: 'settings6',
    iconMask: true
},
    {
    xtype: 'button',
    id: 'filterbutton',
    align: 'right',
    iconCls: 'list',
    iconMask: true
}
]
},

我现在想做什么:

"mainnav[id=mainNav]": {
        back: 'showButtons',
    },

当用户点击后退按钮时触发(无论他是否在 newsDetail 或 eventsDetail 中标识),但我想知道用户在点击后退按钮后看到的是哪个视图。

如果他看到新闻列表,那么我想显示两个按钮(过滤器和查看),但是他看到事件列表我只想显示一个按钮。我需要类似的东西:

showButtons: function(component, options) {
  if(Ext.getCmp(backButton).down().getId() == 'newsList'){
    //show 2 buttons
  }else{
    //show one button
  }
}

对不起,如果答案令人困惑......我不知道如何更好地解释它。无论如何,我将不胜感激任何帮助/想法!

4

2 回答 2

0

面板没有返回事件。所以它永远不会被解雇。

mainnav 是您定义的自定义 xtype 吗?否则该选择器也是错误的。

于 2013-04-11T07:43:04.587 回答
0

得到了解决方案:

    var activePanel = Ext.getCmp('MainTabPanel').getActiveItem();
    var activeItem = activePanel.getItemId();

    if(activeItem == 'newsList'){
        this.filterNewsStore();
        Ext.getCmp('showSettingsButton').show();
        Ext.getCmp('filterButton').show();
    }

    if(activeItem == 'eventList'){
        this.filterEventsStore();
        Ext.getCmp('showSettingsButton').hide();
        Ext.getCmp('filterButton').show();
    }

当后退按钮被触发时,我调用此代码。

于 2013-04-13T10:53:48.830 回答