Hybrid View

  1. #1
    Sencha User
    Join Date
    Sep 2012
    Posts
    29
    Vote Rating
    0
    cassiopeia is on a distinguished road

      0  

    Default Answered: Problem setting record to panel from controller

    Answered: Problem setting record to panel from controller


    Hi,

    I work with MVC.
    I have a navigationview with a list. when you press the disclose button, an event is fired. the chosen record is passed with the event.

    within the controller, I create a detailsview (this is a Panel), I add the record and then I push this detailsview onto the navigationview. the detailsview has fields which names correspond with the names from the model.

    the problem is that I see the detailsview but the fields are empty.
    The record isn't empty within the controller.



    controller:
    Code:
    onMyRequestsDetails : function(record) {
                    //this is the navigationview which is defined within REFS
                    var view = this.getMyRequests();
                    
                    //this is the detailsview
                    var request = Ext.create('LeaveRequest.view.Request' , {scrollable:true}) ;
                    
                    //the record I want to add
                    request.setRecord(record) ;
                    
                    //push details on navigationview
                    view.push(request);
                }
    Detailsview:
    Code:
    ...
    initialize : function() {
    
                    this.callParent(arguments);
    
                   var leaveType = {
                        xtype : 'selectfield',
                        name : 'AbsenceTypeName',
                        id : 'AbsenceTypeName',
                        label : 'Leave type',
                        store : storeAT,
                        valueField : 'AbsenceTypeCode',
                        displayField : 'AbsenceTypeName',
                        cls : 'requestLeaveType'
    
                    };
    
    ...
    this.add([leaveType]);
    
    ...
    Can somebody help?

  2. Is LeaveRequest.view.Request a form panel?

  3. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,347
    Answers
    3542
    Vote Rating
    846
    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


    Is LeaveRequest.view.Request a form panel?
    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.

  4. #3
    Sencha User
    Join Date
    Sep 2012
    Posts
    29
    Vote Rating
    0
    cassiopeia is on a distinguished road

      0  

    Default


    I just tested it and it works!
    I had Ext.Panel, not Ext.form.Panel

    Thank you so much, I've been searching for days

  5. #4
    Sencha User
    Join Date
    Sep 2012
    Posts
    29
    Vote Rating
    0
    cassiopeia is on a distinguished road

      0  

    Default


    Unfortunatelly, this doesn't work for selectfield =(
    textfields, no problem. so the code below will work, but I need a selectfield.

    Code:
    ... initialize : function() {                  this.callParent(arguments);                 var leaveType = {                     xtype : 'textfield',                     name : 'AbsenceTypeName',                     id : 'AbsenceTypeName',                     label : 'Leave type',                     //store : storeAT,                     //valueField : 'AbsenceTypeCode',                     //displayField : 'AbsenceTypeName',                     cls : 'requestLeaveType'                  };  ... this.add([leaveType]);  ...
    Do I need to do something special for this?

  6. #5
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,347
    Answers
    3542
    Vote Rating
    846
    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


    The value you pass must be a value in the store based on the valueField. It will work just like any other field.
    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.

  7. #6
    Sencha User
    Join Date
    Sep 2012
    Posts
    29
    Vote Rating
    0
    cassiopeia is on a distinguished road

      0  

    Default


    It still doesn't work

    Even when I pass an hardcoded value from the controller to the panel
    (AbsenceTypeCode : '0101')
    it will always display the first value from the store.

    Code:
    leaveType = {
                        xtype : 'selectfield',
                        name : 'AbsenceTypeCode',
                        id : 'AbsenceTypeCode',
                        label : 'Leave type',
                        store : storeAT,
                        valueField : 'AbsenceTypeCode',
                        displayField : 'AbsenceTypeName',
                        cls : 'requestLeaveType'
    
                    };

Thread Participants: 1

Tags for this Thread