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
    36,756
    Answers
    3462
    Vote Rating
    828
    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
    36,756
    Answers
    3462
    Vote Rating
    828
    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'
    
                    };

  8. #7
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,756
    Answers
    3462
    Vote Rating
    828
    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


    If the select field does not have a record by default the first option is picked. Here is an example of setRecord:

    Code:
    Ext.define('MyModel', {
        extend : 'Ext.data.Model',
    
        config : {
            fields : [
                'text',
                'select'
            ]
        }
    });
    
    Ext.Viewport.add({
        xtype : 'formpanel',
        items : [
            {
                xtype : 'textfield',
                label : 'Text',
                name  : 'text'
            },
            {
                xtype   : 'selectfield',
                label   : 'Select',
                name    : 'select',
                store   : {
                    fields : [
                        'text',
                        'value'
                    ],
                    data   : [
                        { text : 'First Option',  value : 'first'  },
                        { text : 'Second Option', value : 'second' },
                        { text : 'Third Option',  value : 'third'  }
                    ]
                }
            },
            {
                xtype   : 'button',
                text    : 'Set Value',
                handler : function(btn) {
                    var form = btn.up('formpanel'),
                        rec  = new MyModel({
                            text   : 'Foo',
                            select : 'second'
                        });
    
                    form.setRecord(rec);
                }
            }
        ]
    });
    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.

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

      0  

    Default


    Thank you!
    I finally found the problem.

    I fill the selectfield with data from a store.

    Code:
    storeAT = Ext.create('LeaveRequest.store.AbsenceTypeStore');
    ...
    var leaveType =
    {
                        xtype : 'selectfield',
                        name : 'AbsenceTypeCode',
                        id : 'AbsenceTypeCode',
                        label : 'AbsenceTypeCode',
                        store : storeAT,
                        valueField : 'AbsenceTypeCode',
                        displayField : 'AbsenceTypeName'
    }
    The problem is that the fields of the selectfield have a different name than 'value' and 'text'.
    So when I tried to set a different value, it couldn't match with anything from the options in selectfield,
    so it just showed the first one.

    So, when i replace the bold code above into this:

    Code:
    store : {
                            fields : ['text', 'value'],
                            data : [{
                                        
                                        value : '0200',
                                        text : 'Vacation'
                                    }, {
                                        
                                        value : '0100',
                                        text : 'Sickness'
                                    }]
                        }
    then it works.
    so i can't use a store in a selectfield.

Thread Participants: 1

Tags for this Thread

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi