1. #1
    Sencha User
    Join Date
    Feb 2013
    Posts
    7
    Vote Rating
    0
    dpir is on a distinguished road

      0  

    Default Unanswered: how i can load a new view with a button and can set record data?

    Unanswered: how i can load a new view with a button and can set record data?


    hi

    i am very new to sencha touch and have some problems...

    in my app i have different view. at the beginning i have liste and navigate withe controller using 'itemtap'. by this way i have data from the record and can set the data to the next view. first i load data in different stores from an jason file.

    on 1 view i have first some text and then an button and this button should load a new view. with 'fireEvent' i trigger the controller and with this triggername go to an function to load a new view. i think at this point i lost my data.

    how can i give data to a view with 'fireEvent'?

    this is the controller:

    Code:
    Ext.define('ElectroRadar.controller.Dates', {
        extend: 'Ext.app.Controller',
    
        config: {
            refs: {
                datesContainer: 'datesContainer',
                dates: 'datesContainer dateslist',
                dates_oneday: 'dates_oneday',
                eventdetail: 'eventdetail',
                dates_eventinfo: 'dates_eventinfo',
                eventinfolinks: 'eventinfolinks',
                location_info: 'location_info'
            },
            control: {
                dates: {
                    itemtap: 'onDateTap',
    //                activate: 'onDatesActivate'
                },
                dates_oneday: {
                    itemtap: 'onDayTap',
                },
                eventdetail: {
                    loadLocationInfo: 'loadLocationInfo'
                }
            }
        },
        
        onDateTap: function(list, index, el, record) {
            
            // store definieren
            var daysEventStore = Ext.getStore('DatesEvent'),
            //liste der events
            eventIds = record.get('eventIds');        
            
            
            daysEventStore.clearFilter();
            // filter welche id ist in der eventlist id
            daysEventStore.filterBy(function(party) {
                return Ext.Array.contains(eventIds, party.get('event_id'));
            });                
            
            if (!this.dates_oneday) {
                this.dates_oneday = Ext.widget('dates_oneday');
            }        
        
            this.dates_oneday.setRecord(record);
            this.dates_oneday.config.title = record.get('show_date');        
            this.getDatesContainer().push(this.dates_oneday);
        },
        
        onDayTap: function(list, index, el, record) {        
        
            
            if (!this.eventdetail) {
                this.eventdetail = Ext.widget('eventdetail');
            }        
                    
            this.eventdetail.config.title = record.get('location_name');        
            this.getDatesContainer().push(this.eventdetail);
            this.getDates_eventinfo().setRecord(record);
            this.eventdetail.setRecord(record);
            
        }    ,
        
        loadLocationInfo: function() {
            
            // store definieren
            var locationsStore = Ext.getStore('Locations');
            
            if (!this.location_info) {
                this.location_info = Ext.widget('location_info');
            }        
            
        //    console.log(locationsStore);
        //    this.location_info.config.title = 'jiijij';        
            this.getDatesContainer().push(this.location_info);
            this.location_info.setRecord(locationsStore);
        }
        
        
    });
    and this the view with the button:

    Code:
    Ext.define("ElectroRadar.view.dates.EventDetail", {
    
        extend: 'Ext.Container',
        xtype: 'eventdetail',
    
        config: {
            
    //        layout: 'vbox',
            scrollable: true,
    
            items: [
                {
                    xtype: 'dates_eventinfo'
                },
                {
                    xtype: 'eventinfolinks'
                }
            ]
    
        },
        
    initialize: function() {
    
        
        
                var Button = {
                xtype: "button",
                iconCls: "trash",
                text: 'weiter',
                handler: function() {
                    this.fireEvent('loadLocationInfo', this)
                },
                scope: this
            };
            
            this.add([
                Button
            ]);        
            
    }
        
        
    });
    here you can see my test app:
    http://wachtelborn.net/_ansicht/event/mobile/4/

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,647
    Vote Rating
    899
    Answers
    3575
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    I'm not sure you are giving enough. So you have a button that fires the loadLocationInfo event and you want to pass a record in the event?
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Feb 2013
    Posts
    7
    Vote Rating
    0
    dpir is on a distinguished road

      0  

    Default


    i solved it

    with findRecord i take 1 item from the store and i use a value from loading the last view. i think it is not the best way, but it works for now ;-)

    Code:
     loadLocationInfo: function() {
            
            // locationstore definieren
            var locationsStore = Ext.getStore('Locations');        
            
            locationsStore.clearFilter();        
            // 1 location filtern
            locationsStore.filter('location_name', this.locationId);    
            
        //    console.log(locationsStore.get('xindex'));    
                    
            // store mit nur 1 location
            this.oneLocation = locationsStore.findRecord('location_name', this.locationId);
    
            if (!this.location_info) {
                this.location_info = Ext.widget('location_info');
            }        
            
            this.location_info.config.title = this.oneLocation.get('location_name');        
            this.getDatesContainer().push(this.location_info);
            this.location_info.setRecord(this.oneLocation);
                    
        },
        
        LocationMap: function() {                            
            
            if (!this.location_map) {
                this.location_map = Ext.widget('location_map');
            }        
            
            this.location_map.config.title = this.oneLocation.get('location_name');        
            this.getDatesContainer().push(this.location_map);
            this.location_map.setRecord(this.oneLocation);
        
        }

Thread Participants: 1