-
23 Jan 2012 2:02 PM #1
Answered: Big problem -> load data to form width dynamic selectfield
Answered: Big problem -> load data to form width dynamic selectfield
I have a big problem, I have to use Ext.Function.defer (function () {...}); to delay the loading of dynamic selectfield
jet or some other method to load the data after loading all the stories selectfield ???????
Please HELP!
PHP Code:Ext.define('SIMOBILE.view.Edition', {
extend: 'Ext.tab.Panel',
xtype: 'edition',
config: {
myid: null,
mytype: null,
ui: 'dark',
tabBarPosition: 'top',
tabBar: {
layout: {
pack: 'center'
}
},
activeTab:0
},
constructor: function(config) {
var me = this;
var xItems = {
items: [
{
title: langX.xGeneral,
xtype: 'formpanel',
layout: {
type : 'vbox',
align: 'stretch'
},
items: [
{
xtype: 'fieldset',
title: langX.xClientInformation,
defaults: {
required : true,
labelAlign: 'left',
labelWidth: '30%'
},
items: [
{
xtype: 'fieldset',
title: langX.xInvoiceInformation,
defaults: {
required : true,
labelAlign: 'left',
labelWidth: '30%'
},
items: [
{
xtype: 'textfield',
name: 'title',
label: langX.xTitle
},
{
xtype: 'selectfield',
name : 'currency',
label: langX.xCurrency,
placeHolder: 'Select...',
valueField : 'currency_id',
displayField : 'currency_name',
store: Ext.create('SIMOBILE.store.Currency', {})
},
{
xtype: 'selectfield',
name : 'account_id',
label: langX.xAccount,
placeHolder: 'Select...',
valueField : 'account_id',
displayField : 'account_title',
store: Ext.create('SIMOBILE.store.Account', {})
}
]
}
]
}
]
};
config = Ext.apply(xItems, config);
me.callParent([config]);
},
updateData: function(newData) {
var me = this;
var x = me.down('formpanel');
var c = x.getFields();
me.setMask({
message: langX.xLoading
});
Ext.Ajax.request({
url: '/route.php?params='+this.getMytype()+'/id/'+this.getMyid(),
actionMethods: 'POST',
scope:this,
success: function(r, o) {
var datax = Ext.JSON.decode(r.responseText);
Ext.Function.defer(function(){
x.loadModel(
Ext.create('SIMOBILE.model.Edition', {
'currency': datax.currency_id,
'title': datax.bill_title,
'account_id': datax.bill_account
}
));
me.unmask();
}, 1500);
},
failure: function(r,o) {
me.unmask();
}
});
}
});
-
Best Answer Posted by rdougan
What I would do is load the store of the dynamic selectfield, then when it is loaded, set the value of the field with the new correct value you got from the Ajax request.
Sorry if I am not understanding you..Code://load data var data = {fieldValue: 1}; //create a field field = Ext.create('Ext.field.Select', ...); //load the store with a callback field.getStore().load(function() { field.setValue(data.fieldValue); });
-
23 Jan 2012 3:00 PM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,624
- Vote Rating
- 435
- Answers
- 3106
So you need to use loadRecord on the form after the store of a selectfield is finished loading?
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
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 almost in print!
When posting code, please use BBCode's CODE tags.
-
23 Jan 2012 3:05 PM #3
Hey,
I want to change value of dynamic select field,
and I can change only after everything is loaded in a form
an idea - an example?
-
23 Jan 2012 3:19 PM #4
You mean, you want to load the store that is binded to the Select field? If so, you will need to make another Ajax request and call the Ext.field.Select#setStore method and then call the Ext.field.Select#setValue.
Sencha Inc.
Robert Dougan - @rdougan
Sencha Touch 2 and Ext JS 4 Core Team Member, SASS/Theming Wizard.
-
23 Jan 2012 3:39 PM #5
task:
1) I have a list and I want to modify the record
2) I click - convey to the form id
3) generates a field in a form (for example, I have 3 selectfield field type - for which data are retrieved [options] - using ajax store)
PHP Code:{
xtype: 'selectfield',
name : 'currency',
label: langX.xCurrency,
placeHolder: 'Select...',
valueField : 'currency_id',
displayField : 'currency_name',
store: Ext.create('SIMOBILE.store.Currency', {})
},
PHP Code:Ext.define('SIMOBILE.model.Currency', {
extend: 'Ext.data.Model',
myid: null,
fields: [
{
name: 'currency_id',
type: 'int'
},
{
name: 'currency_name',
type: 'string'
}
],
proxy: {
type: 'ajax',
url : '/route.php?params=currency',
actionMethods: 'POST',
reader: {
type: 'json',
root: function(data) {
if (data.error) {
return [];
} else {
return data;
}
}
}
}
});
Ext.define('SIMOBILE.store.Currency', {
extend: 'Ext.data.Store',
model: 'SIMOBILE.model.Currency',
requires: ['SIMOBILE.model.Currency'],
autoLoad: true
});
4) then I need to provide data relevant to the form - and I can only do this when all selectfield store will be downloaded.
in extjs3 this problem was not
Please help in solving this problem ...
-
23 Jan 2012 3:52 PM #6
What I would do is load the store of the dynamic selectfield, then when it is loaded, set the value of the field with the new correct value you got from the Ajax request.
Sorry if I am not understanding you..Code://load data var data = {fieldValue: 1}; //create a field field = Ext.create('Ext.field.Select', ...); //load the store with a callback field.getStore().load(function() { field.setValue(data.fieldValue); });
Sencha Inc.
Robert Dougan - @rdougan
Sencha Touch 2 and Ext JS 4 Core Team Member, SASS/Theming Wizard.
-
23 Jan 2012 3:59 PM #7
perhaps the solution will keep getting all incontroller store (stores [...])
and retrieve data by Ext.StoreMgr.get ('Currency').
- I checked and it works as I wanted ---
But do not change the fact that the problem occurs in the case of dependent story - the passed ID
-
23 Jan 2012 4:00 PM #8
Sorry, still not understanding much.

You mean that setting the value of the Select field is not working? If so, I have fixed a bunch of issues with Select field for the next release. Which will be released in the next few days.Sencha Inc.
Robert Dougan - @rdougan
Sencha Touch 2 and Ext JS 4 Core Team Member, SASS/Theming Wizard.
-
23 Jan 2012 4:02 PM #9
-
23 Jan 2012 4:10 PM #10
Rdougan - thank you for your help ;-)
You can even refine: datepickerfield
and add the option "dateformat" - as for me, it is essential


Reply With Quote