Home > DeveloperSection > Forums > Pushing a new view after an item was tapped in Sencha Touch 2
Pravesh Singh

Total Post:411

Points:2881
Posted on    June-03-2013 2:28 AM

 Sencha Touch Sencha Touch 
Ratings:


 1 Reply(s)
 1762  View(s)
Rate this:
Hi,

I have a simple list populated from JSON. When tapping one of the items i want a new view to appear. The List is inside an Ext.navigation.View.

My controller

Ext.define('Trainz.controller.StationListController', {
extend: 'Ext.app.Controller',
config: {
    models: [
        'Station'
    ],
    stores: [
        'Stations'
    ],
    views: [
        'Main'
    ],

    control: {
        "list": {
            itemtap: 'onListItemTap'
        }
    }
},

onListItemTap: function(dataview, index, target, record, e, eOpts) {
    console.log(record);
}

});
And here is the (now empty) view i want to push

Ext.define('Trainz.view.StationDetailView', {
extend: 'Ext.Panel',

config: {
}

});

Guessing i have to put something in the onListItemTap function but for the life of me I cant figure out what. Tried over four different code snippets from Google and just got errors back. Whats the proper way?

I'm using Sencha Architect if that makes any difference.

Here is the complete initial view for reference:

Ext.define('Trainz.view.Main', {
extend: 'Ext.tab.Panel',

config: {
    tabBar: {
        docked: 'bottom'
    },
    items: [
        {
            xtype: 'navigationview',
            title: 'Stations',
            iconCls: 'maps',
            items: [
                {
                    xtype: 'list',
                    title: 'Stations',
                    itemTpl: [
                        '<div>{Namn}</div><div style="float:right; margin-right: 1.5em;"></div>'
                    ],
                    store: 'Stations',
                    grouped: true,
                    indexBar: true
                }
            ]
        }
    ]
}
});

Thanks in advance. 


AVADHESH PATEL

Total Post:604

Points:4228
Posted on    June-03-2013 9:00 AM

Hi Pravesh!

You need to retrieve your navigationview and then do navigationView.push(yourNewView); 

or

dataview.up('navigationview').push(yourNewView)

I hope it resolve your problem.

Don't want to miss updates? Please click the below button!

Follow MindStick