safewolf
1 Apr 2008, 3:10 AM
I hava a formpanel,I want to do like this:
When rending the panel,it will be feed with a json data.In the data,there's a field notifys the panel if need expand a fieldset.
the jason is like this:
{"success":"true","rows":[{"0":"22","id":"4","1":"user2","username":"user2","deafult_number":"1","deafult_email":"1"}]}
and the fieldset is:
{
xtype:'fieldset',
checkboxToggle:true,
checkboxName:'deafult_number',
title: 'Default Mobile',
autoHeight:true,
defaults: {width: 150},
defaultType: 'textfield',
listeners:{'collapse':function(obj){
if(Ext.getCmp('countrycodes')){
Ext.getCmp('countrycodes').allowBlank = true;
Ext.getCmp('mobile_number').allowBlank = true;
}
},
'expand':function(obj){
Ext.getCmp('countrycodes').allowBlank = false;
Ext.getCmp('mobile_number').allowBlank = false;
}
},
collapsed: true,
items :[new Ext.form.ComboBox({
fieldLabel: 'Country Code',
name:'countrycodes',
hiddenName:'mobile_country_code',
id:'countrycodes',
forceSelection: true,
listWidth: 200,
store: new Ext.data.SimpleStore({
fields: ['value', 'text'],
data : CountryCode
}),
valueField:'value',
displayField:'text',
typeAhead: true,
mode: 'local',
triggerAction: 'all',
selectOnFocus:true
})
the fieldset is collapsed usually,but I need it expands when the "deafult_number" equals "1" in the json data
I write like this in the formpanel's code:
form = new Ext.FormPanel({
labelWidth: 180, // label settings here cascade unless overridden
url:'ext_user.php?action=edit',
frame:true,
region:'center',
title : "Add User",
bodyStyle:'padding:5px 5px 0',
width: 430,
reader: new Ext.data.JsonReader
({successProperty: 'success',
root: 'rows'},
[
{name:'id'},
{name:'contact_country_code',mapping:'contact_country_code'},
{name:'contact_mobile_number',mapping:'contact_mobile_number'},
{name:'deafult_number',mapping:'deafult_number'},
{name:'deafult_email',mapping:'deafult_email'}
]),
but it seem to be wrong:(
so poor english,anybody can understand?
When rending the panel,it will be feed with a json data.In the data,there's a field notifys the panel if need expand a fieldset.
the jason is like this:
{"success":"true","rows":[{"0":"22","id":"4","1":"user2","username":"user2","deafult_number":"1","deafult_email":"1"}]}
and the fieldset is:
{
xtype:'fieldset',
checkboxToggle:true,
checkboxName:'deafult_number',
title: 'Default Mobile',
autoHeight:true,
defaults: {width: 150},
defaultType: 'textfield',
listeners:{'collapse':function(obj){
if(Ext.getCmp('countrycodes')){
Ext.getCmp('countrycodes').allowBlank = true;
Ext.getCmp('mobile_number').allowBlank = true;
}
},
'expand':function(obj){
Ext.getCmp('countrycodes').allowBlank = false;
Ext.getCmp('mobile_number').allowBlank = false;
}
},
collapsed: true,
items :[new Ext.form.ComboBox({
fieldLabel: 'Country Code',
name:'countrycodes',
hiddenName:'mobile_country_code',
id:'countrycodes',
forceSelection: true,
listWidth: 200,
store: new Ext.data.SimpleStore({
fields: ['value', 'text'],
data : CountryCode
}),
valueField:'value',
displayField:'text',
typeAhead: true,
mode: 'local',
triggerAction: 'all',
selectOnFocus:true
})
the fieldset is collapsed usually,but I need it expands when the "deafult_number" equals "1" in the json data
I write like this in the formpanel's code:
form = new Ext.FormPanel({
labelWidth: 180, // label settings here cascade unless overridden
url:'ext_user.php?action=edit',
frame:true,
region:'center',
title : "Add User",
bodyStyle:'padding:5px 5px 0',
width: 430,
reader: new Ext.data.JsonReader
({successProperty: 'success',
root: 'rows'},
[
{name:'id'},
{name:'contact_country_code',mapping:'contact_country_code'},
{name:'contact_mobile_number',mapping:'contact_mobile_number'},
{name:'deafult_number',mapping:'deafult_number'},
{name:'deafult_email',mapping:'deafult_email'}
]),
but it seem to be wrong:(
so poor english,anybody can understand?