Results 1 to 2 of 2

Thread: How to get and send values from controller to form and viceversa

  1. #1
    Sencha User
    Join Date
    Dec 2012
    Posts
    43
    Vote Rating
    1
      0  

    Default How to get and send values from controller to form and viceversa

    Hi all,
    I am using deftjs with Extjs.
    I want fetch the data from server and show it in the form.
    Data is coming from server, But I am unable to set it to the form. Please tell me the solution to this.
    My code is here...

    in controller :
    Ext.define("ABC.controller.DetailsController", {
    extend: "Deft.mvc.ViewController",
    mixins:[ 'Deft.mixin.Controllable', 'Deft.mixin.Injectable' ],
    inject :['detailStore'],
    config:{
    detailStore : null,
    details : null
    },
    control : {

    DetailsUpdate:{
    click : 'onDetailsUpdateClick'
    }
    },
    init: function() {

    var _this = this;
    var initialDetails = this.loadDetails();
    initialDetails.then({success: loadDetailsSuccess, failure: loadDetailsFailure,progress: progressCallback});
    function loadDetailsSuccess(result){
    console.dir(result);
    };
    function loadDetailsFailure(result){
    console.dir(result);
    };
    function progressCallback(result){
    console.dir(result);
    };

    return this.callParent(arguments);
    },

    loadDetails: function() {
    var deferred;
    deferred = Ext.create("Deft.promise.Deferred");
    this.getDetailStore().load({
    callback: function(records, operation, success) {
    if (success) {
    return deferred.resolve(records);
    } else {
    return deferred.reject("Error loading Scenarios");
    }
    },
    scope: this
    });
    return deferred.promise;
    },

    onDetailsUpdateClick : function(){
    console.dir(this.getView);
    console.log('officeDetails controller');
    console.dir(this.getDetails());
    }

    });

    in form :
    Ext.define("ABC.view.Settings", {
    extend: 'Ext.form.Panel',
    alias: "widget.abc-view-Settings",
    mixins:[ 'Deft.mixin.Controllable', 'Deft.mixin.Injectable' ],
    controller : 'ABC.controller.DetailsController',
    initComponent : function(){
    Ext.applyIf(this,{ bodyPadding: 5,
    autoScroll: true,
    fieldDefaults: { msgTarget: 'under',
    },
    layout: {
    type: 'vbox',
    pack: 'start',
    padding: 5,
    align: 'stretch'
    },
    items : [{
    layout : {
    type : 'vbox',
    pack : 'start'
    },
    defaults : {
    margins : '0 0 10 0'
    },
    border : false,
    items : [{
    layout : {
    type : 'hbox',
    pack : 'start'
    },
    width : '100%',
    border : false,
    defaults : {
    margin : '0 10 0 0'
    },
    items : [{
    xtype : 'textfield',
    name : 'name',
    fieldLabel : 'Name',
    labelSeparator : "",
    readOnly : true,
    // disable : true,
    width : '60%',

    // allowBlank : false,
    labelAlign : 'left'
    },{
    xtype : 'combo',
    fieldLabel : 'TimeZone',
    labelSeparator : "",
    width : '30%',
    // allowBlank : false,
    labelAlign : 'left'
    }]
    },{
    layout : {
    type : 'hbox',
    pack : 'start'
    },
    border : false,
    width : '100%',
    defaults : {
    margin : '0 10 0 0'
    },
    items : [{
    xtype : 'textfield',
    name : 'address1',
    fieldLabel : 'Address 1',
    labelSeparator : "",
    width : '50%',
    // allowBlank : false,
    labelAlign : 'top'
    },{
    xtype : 'textfield',
    name : 'address2',
    fieldLabel : 'Address 2',
    labelSeparator : "",
    width : '50%',
    // allowBlank : false,
    labelAlign : 'top'
    }]
    }],
    buttons : [{
    text : 'Update',
    itemId : 'DetailsUpdate'
    }]
    });
    }
    });

  2. #2
    Ext JS Premium Member tvanzoelen's Avatar
    Join Date
    Apr 2008
    Location
    Groningen - Netherlands
    Posts
    1,199
    Answers
    87
    Vote Rating
    44
      0  

    Default

    After loading the store, get the reference to your form and use

    Code:
    form.loadRecord(record)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •