1. #1
    Sencha User
    Join Date
    Jul 2011
    Posts
    18
    Vote Rating
    0
    tvance929 is on a distinguished road

      0  

    Default Unanswered: Changes pages and send record to new 'page' with a list itemTap

    Unanswered: Changes pages and send record to new 'page' with a list itemTap


    I can change the page but cannot figure out how to send the record properly to the controller of the view that just got shown...

    Code:
     tappedPresentation: function (list, index, target, record) {
            Ext.getCmp('Viewport').setActiveItem(1);
            // alert(record.data.title);
        }
    I know this will change pages and I know the controller picks up when that view is shown ...

    Code:
     control: {
                'presentPanel': {
                    show: 'testShow'
                }
            }
    But how do I pass the record that was chosen?

  2. #2
    Sencha User
    Join Date
    Jul 2011
    Posts
    18
    Vote Rating
    0
    tvance929 is on a distinguished road

      0  

    Default


    Nevermind, I just used sessionStorage. Not sure if that is the right way to do it, but it gets the job done.

  3. #3
    Sencha User Kikketer's Avatar
    Join Date
    Apr 2012
    Location
    Wausau, WI
    Posts
    135
    Answers
    6
    Vote Rating
    8
    Kikketer will become famous soon enough

      0  

    Default


    Ick session storage
    The importance is knowing the roles of the controller and the view, and the arguments that are sent in through the events.

    The view would have it's own listener for the tap of the list item. This listener automatically gets the item that was tapped as an argument. These arguments are in the API documentation, but it's also helpful to put a breakpoint in the triggered function and see what the "arguments" variable has.
    Code:
      onDiscloseTap: function(list, item) {
        this.fireEvent("editCandidateCommand", item);
      },
    The view fires this event, and takes any number of parameters after the name of the event. These parameters are sent to the controller or anyone else that's listening.

    The controller in this case has a reference to the view (the string is the xtype or alias):
    Code:
        refs: {
          candidateList: "candidateList"
        },
    Once it has reference to this view, it can listen for events that are fired off that view using the "control":
    Code:
        control: {
          candidateList: {
            editCandidateCommand: "onEditCandidate"
          }
        }
    Finally the function called "onEditCandidate" gets the arguments you initially sent with the event:
    Code:
      onEditCandidate: function(candidate) {
        var detailForm = this.getDetailForm();  //From the refs that I didn't type out
        detailForm.setRecord(candidate); // The detail form is a form.Panel that has a setRecord() function
        // Make the next view show up:
        Ext.Viewport.animateActiveItem(entryForm, {type: "slide", direction: "left"});
      },
    Hope this helps a bit!

  4. #4
    Sencha User
    Join Date
    Feb 2011
    Location
    Düsseldorf, Germany
    Posts
    585
    Answers
    34
    Vote Rating
    32
    Kurt001 has a spectacular aura about Kurt001 has a spectacular aura about

      0  

    Default


    Or you could go with routing:
    Code:
    MyApp.app.redirecTo('nextPage/' + recordId)
    if you go with autocreate you can do the following in the controller:
    Code:
    config: {
        routes: {
            'nextPage/:recordId' : 'index'
        }
    },
    
    index: function (recordId) {
        Ext.Viewport.add(this autocreated view);
        // here we go with the recordID or recordPos in store.
    }

Thread Participants: 2

Tags for this Thread