1. #1
    Sencha User
    Join Date
    Oct 2012
    Posts
    14
    Vote Rating
    0
    mlourdes is on a distinguished road

      0  

    Default populate selectedField inside form with a nested store

    populate selectedField inside form with a nested store


    Hi ,
    I have a form with a selected field that I would like to edit .
    When loading the form the selected fields does not show the values that are already stored .
    I have two models


    Ext.define('app.model.mdcustomer', {
    extend: 'Ext.data.Model',
    alias: 'model.md',


    uses: [
    'app.model.mdvendorToSite'
    ],


    config: {
    hasOne: {
    associationKey: '',
    model: 'app.model.mdvendorToSite',
    primaryKey: 'siteId',
    getterName: 'getSite',
    foreignKey: 'vendorToSite_id',
    setterName: 'setSite'
    },
    fields: [
    {
    name: 'vendorToSite_id',
    type: 'int'
    },
    {
    name: 'account',
    type: 'string'
    },...

    extend: 'Ext.data.Model',


    config: {
    idProperty: 'siteId',
    fields: [
    {
    name: 'site',
    type: 'string'
    },
    {
    name: 'siteId',
    type: 'int'
    }
    ],
    proxy: {
    type: 'ajax',
    url: 'Data/VendorToSite.json',
    reader: {
    type: 'json',
    rootProperty: 'vendorToSite'
    }
    }
    }
    });

    I want to show in a form "customer" , the right value in selected field

    {
    xtype: 'selectfield',
    width: '50%',
    label: 'Vendor To Site',
    labelAlign: 'top',
    displayField: 'site',
    store: 'st_VendorToSite',
    valueField: 'siteId'
    }

    I am loading the form like :
    frmEdit.setRecord(storeCustomer.getAt(0));

  2. #2
    Sencha - Architect Dev Team aconran's Avatar
    Join Date
    Mar 2007
    Posts
    8,185
    Vote Rating
    63
    aconran is just really nice aconran is just really nice aconran is just really nice aconran is just really nice aconran is just really nice

      0  

    Default


    Are both of the other stores (st_VendorToSite for example) already loaded before you invoke setRecord?
    Aaron Conran
    @aconran
    Sencha Architect Development Team

  3. #3
    Sencha User
    Join Date
    Oct 2012
    Posts
    14
    Vote Rating
    0
    mlourdes is on a distinguished road

      0  

    Default Selected field in editable Form

    Selected field in editable Form


    It was solved , I have associations foreign key , primary key disagreement , and the most important thing the property name in my select control (by default "picker"), I was paying attention to the Id.

  4. #4
    Sencha - Architect Dev Team aconran's Avatar
    Join Date
    Mar 2007
    Posts
    8,185
    Vote Rating
    63
    aconran is just really nice aconran is just really nice aconran is just really nice aconran is just really nice aconran is just really nice

      0  

    Default


    Glad, you got it.
    Aaron Conran
    @aconran
    Sencha Architect Development Team