zhxhdean
31 Aug 2011, 7:11 PM
<script type="text/javascript">
Ext.onReady(function () {
Ext.define("dflModel", {
extend: "Ext.data.Model",
fields: [
{ name: "id", type: "int" },
{ name: "text", type: "string" }
]
});
var states = Ext.create('Ext.data.Store', {
model: "dflModel",
proxy: {
url: "loaddata.ashx",
type: "ajax"
}
,autoLoad: true
})
var defaults = Ext.create('Ext.data.Store', {
fields: ['id', 'text'],
data: []
})
var panel = Ext.create('Ext.form.Panel', {
id: 'formcom',
title: 'combo',
width: 500,
frame: true,
renderTo: Ext.getBody(),
defaultType: 'combo',
items: [{
id: 'combo1',
xtype: 'combo',
fieldLabel: 'city',
labelWidth: 20,
emptyText: 'select',
editable: false,
queryMode: 'local',
store: states,
displayField: 'text',
valueField: 'id',
listeners: {
select: function (combo, record, index) {
scombox.clearValue();
scombox.store = new Ext.data.Store({
model: 'dflModel',
proxy: {
url: "loaddata.ashx?cityid=" + combo.value,
type: "ajax"
}
,autoLoad: true
});
defaults.load();
}
}
}]
})
var scombox = Ext.create('Ext.form.field.ComboBox', {
id: 'combo2',
fieldLabel: 'area',
labelWidth: 20,
store: defaults,
editable: false,
queryMode: 'local',
displayField: 'text',
valueField: 'id',
margin: '-2 0 0 180',
emptyText: 'select',
triggerAction: 'all',
renderTo: Ext.getCmp('formcom').getEl() //Ext.getBody()//
})
})
</script>
Server Data
[{"id":11,"text":"beijing"},{"id":12,"text":"shanghai"},{"id":13,"text":"guangzhou"}]
first combo can load data ,when onselect server side data send to client but second combo can't load data
my english poor , thx
Ext.onReady(function () {
Ext.define("dflModel", {
extend: "Ext.data.Model",
fields: [
{ name: "id", type: "int" },
{ name: "text", type: "string" }
]
});
var states = Ext.create('Ext.data.Store', {
model: "dflModel",
proxy: {
url: "loaddata.ashx",
type: "ajax"
}
,autoLoad: true
})
var defaults = Ext.create('Ext.data.Store', {
fields: ['id', 'text'],
data: []
})
var panel = Ext.create('Ext.form.Panel', {
id: 'formcom',
title: 'combo',
width: 500,
frame: true,
renderTo: Ext.getBody(),
defaultType: 'combo',
items: [{
id: 'combo1',
xtype: 'combo',
fieldLabel: 'city',
labelWidth: 20,
emptyText: 'select',
editable: false,
queryMode: 'local',
store: states,
displayField: 'text',
valueField: 'id',
listeners: {
select: function (combo, record, index) {
scombox.clearValue();
scombox.store = new Ext.data.Store({
model: 'dflModel',
proxy: {
url: "loaddata.ashx?cityid=" + combo.value,
type: "ajax"
}
,autoLoad: true
});
defaults.load();
}
}
}]
})
var scombox = Ext.create('Ext.form.field.ComboBox', {
id: 'combo2',
fieldLabel: 'area',
labelWidth: 20,
store: defaults,
editable: false,
queryMode: 'local',
displayField: 'text',
valueField: 'id',
margin: '-2 0 0 180',
emptyText: 'select',
triggerAction: 'all',
renderTo: Ext.getCmp('formcom').getEl() //Ext.getBody()//
})
})
</script>
Server Data
[{"id":11,"text":"beijing"},{"id":12,"text":"shanghai"},{"id":13,"text":"guangzhou"}]
first combo can load data ,when onselect server side data send to client but second combo can't load data
my english poor , thx