Results 1 to 2 of 2

Thread: Two Way Bindable not working as expected

  1. #1
    Sencha User
    Join Date
    Dec 2015
    Posts
    2

    Default Two Way Bindable not working as expected

    I want to make several components that all get passed chunks of a larger view model. One of the simpler components I want to have is as follows:

    Code:
    Ext.define('MyApp.view.SettingsField', {
      extend: 'Ext.form.FieldContainer',
      xtype: 'settingsfield',
    
    
      viewModel: true,  defaultBindProperty: 'value',
      reference: 'field',
      publishes: ['value', 'disable'],
      twoWayBindable: ['value', 'disable'],
    
    
      config: {
        units: '',
        disable: false,
        maxValue: undefined,
        minValue: undefined,
        value: undefined,
      },
    
    
      initComponent: function() {
        this.items = [{
          xtype: 'numberfield',
          bind: {
             value: '{field.value}',
             disabled: '{field.disable}',
          },
          minValue: this.getMinValue(),
          maxValue: this.getMaxValue(),
        }, {
          xtype: 'checkbox',
          bind: '{!field.disable}',
        }, {
          xtype: 'displayfield',
          value: this.getUnits(),
        }];
    
    
        this.callParent(arguments);
      },
    });
    And I want to be able to use this something like:

    Code:
    [...
    {
        xtype: 'settingsfield',
        fieldLabel: 'Temperature',
        bind: {
            value: '{eqn.input.Temp}',
            disable: '{eqn.option.calculateTemp}'
        },
        minValue: 0,
        maxValue: 400,
        units: '&#8457'
    },
    {
        xtype: 'settingsfield',
        fieldLabel: 'Pressure',
        bind: {
            value: '{eqn.input.Pressure}',
            disable: '{eqn.option.calculatePressure}'
        },
        minValue: 0,
        maxValue: 200,
        units: 'psi'
    },
    ...
    ]
    When I run this code, the values of value and disable never leave the derived component (the bind to '{value}' updates the component's viewmodel value but not the config or value binding from the owning view).

    So, what am I missing about this?

    Thanks for your help!
    Last edited by d3dc; 18 Feb 2016 at 2:50 PM. Reason: Simplified question.

  2. #2
    Sencha User
    Join Date
    Dec 2015
    Posts
    2

    Default

    bump

    I've gone ahead and overridden the updaters to set the view model property, and bound to the view model to set the config property.

    This sounds exactly like what TwoWayBindable should be doing for me... Am I mistaken?
    Last edited by d3dc; 18 Feb 2016 at 2:57 PM. Reason: Quick-reply is horribly broken

Similar Threads

  1. Replies: 2
    Last Post: 16 Feb 2016, 9:03 AM
  2. creating component
    By dmitry.akatev in forum Ext: Q&A
    Replies: 1
    Last Post: 14 Oct 2013, 2:05 PM
  3. Text aliasing in Chrome after animation?
    By jlyman in forum Sencha Touch 2.x: Discussion
    Replies: 2
    Last Post: 31 Jan 2013, 4:11 AM
  4. Replies: 2
    Last Post: 2 Nov 2012, 3:25 PM
  5. Chart aliasing store fields for the legend
    By melmac in forum Ext: Discussion
    Replies: 0
    Last Post: 9 Jun 2011, 6:56 AM

Tags for this Thread

Posting Permissions

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