How to assign Store value to hidden field

杀马特。学长 韩版系。学妹 提交于 2019-12-20 05:44:06

问题


I have a model and store and I need to assign a value to the hidden field from the store.

Ext.define('loginUser', {
            extend: 'Ext.data.Model',
            fields: [               
                { name: 'id', mapping: 'Provider.id' },
                { name: 'name', mapping: 'Provider.name' }
            ]
        });


loggedUser = Ext.create('Ext.data.Store', {
            model: 'loginUser',
            autoLoad: true,
            proxy: {
                type: 'ajax',
                url : url+'/lochweb/loch/users/getLoggedUser',
                reader: {
                 type: 'json',
                 root: 'Users'
                }                   
            }

        });

I need to assign the store value to hidden field as follows,

CProvider = new Ext.create('Ext.ux.form', {
   items: [{
      xtype:'hidden',                       
      name:'clearingHouseID',                       
      store:loggedUser
      value:id
   }]
});

but the value is not assigned to hidden value. Is there any way assign it store value to hidden field?

Thanks


回答1:


You can bind a record to a form by using the form's loadRecord function. Something along these lines:

loggedUser.on('load', function (store, records, success) {
    if (success && records.length === 1) {
       CProvider.loadRecord(records[0]);
    }    
});

Then change the form field to have a name of the field in the model you want to be stored in the hidden field.

CProvider = new Ext.create('Ext.ux.form', {
   items: [{
      xtype:'hidden',                       
      name:'name',                       
      store:loggedUser
      value:id
   }]
});

The hidden field can only store one field's value of the model you are loading into the form.



来源:https://stackoverflow.com/questions/10515600/how-to-assign-store-value-to-hidden-field

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!