求教Ext 省市县的联动代码或例子,急!!!!

dragonsky_w 2010-06-22 02:35:21
求教Ext 省市县的联动代码或例子,急!!!!

最近在做一个项目,里面有用到用户的注册,用户注册中要用到 省、市、县 的联动,

急救!!!!!!

...全文
384 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
no1_yszz 2011-12-15
  • 打赏
  • 举报
回复
人家说的是Ext的三级联动好不好 你说的是什么呀 哥们
自然框架 2011-02-25
  • 打赏
  • 举报
回复
这里有封装好的控件,n级联动无刷新,有源码。有省市区县的数据库
http://topic.csdn.net/u/20110225/16/1aae774d-e92e-4d1f-9065-61b712063c28.html?44405
flash8627 2010-07-02
  • 打赏
  • 举报
回复
郁闷,重写了,还是有哪个BUG

如果先点了city
省就不能正常显示了



Ext.onReady(function(){
var provinceCombo = new Ext.form.ComboBox({
fieldLabel: "所在省",
renderTo : "slideIn",
width: 230,
mode: "remote",
valueField: "id",
triggerAction: "all",
displayField: "name",
hiddenName: "province",
name: "province",
pageSize : 34,
store: new Ext.data.Store({
start : 0,
limit : 34,
totalProperty : "totalProperty",
proxy: new Ext.data.HttpProxy({
url: "areaComplate.action"
}),
reader: new Ext.data.JsonReader({
id: "name",
root: "items"
},
[ "id", "provinceID", "name" ])
}),

listeners: {
select: function(combo, record, index) {
cityCombo.clearValue();
cityCombo.getStore().removeAll();
areaCombo.clearValue();
areaCombo.getStore().removeAll();
cityCombo.getStore().load({
params: {
fatherID : record.get("name")
}
});
}
}

});

var cityCombo = new Ext.form.ComboBox({
fieldLabel: "所在市",
renderTo : "slideIn",
width: 230,
mode: "remote",
valueField: "cityID",
triggerAction: "all",
displayField: "name",
hiddenName: "city",
name: "city",
pageSize : 34,
store: new Ext.data.Store({
start : 0,
limit : 34,
totalProperty : "totalProperty",
proxy: new Ext.data.HttpProxy({
url: "getCity.action"
}),
reader: new Ext.data.JsonReader(
{
id: "name",
root: "items"
},
[ "id", "name", "cityID", "fatherID" ]
)
}),

listeners: {
select: function(combo, record, index) {
areaCombo.clearValue();
areaCombo.getStore().removeAll();
areaCombo.getStore().load({
params: {
fatherID : record.get("name")
}
});
}
}

});

var areaCombo = new Ext.form.ComboBox({
fieldLabel: "所在区",
renderTo : "areaIn",
width: 230,
mode: "remote",
valueField: "id",
triggerAction: "all",
displayField: "name",
hiddenName: "area",
name: "area",
pageSize : 34,
store: new Ext.data.Store({
start : 0,
limit : 34,
totalProperty : "totalProperty",
proxy: new Ext.data.HttpProxy({
url: "getAred.action"
}),
reader: new Ext.data.JsonReader({
id: "name",
root: "items"
},[ "id", "name", "areaID", "fatherID"
]
)
})

});

})
dragonsky_w 2010-06-28
  • 打赏
  • 举报
回复
谢谢了 ,我的问题现在已经解决了,非常感谢!
bonnibell 2010-06-27
  • 打赏
  • 举报
回复
ext 的combo 真的很强啊,随你怎么搞了
zoujp_xyz 2010-06-26
  • 打赏
  • 举报
回复

{
layout: "form",
items: {
xtype: "combo",
fieldLabel: "所在省",
width: 130,
store: new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
url: ""
}),
reader: new Ext.data.JsonReader({
id: "Key",
root: "data"
},
[{
name: "Key"
},
{
name: "Value"
}]),
baseParams: {
action: "GetProvinces"
},
autoLoad: true
}),
mode: "local",
valueField: "Key",
triggerAction: "all",
readOnly: true,
displayField: "Value",
hiddenName: "ProvinceId",
name: "ProvinceId",
listeners: {
select: function(combo, record, index) {
win.dealStoreWin.get(0).form.findField("CityId").clearValue();
win.dealStoreWin.get(0).form.findField("CityId").getStore().load({
params: {
args: record.id
}
});
}
}
},
columnWidth: .5
}]
},
{
layout: "column",
items: [{
layout: "form",
items: {
xtype: "combo",
fieldLabel: "所在市",
width: 130,
store: new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
url: ""
}),
reader: new Ext.data.JsonReader({
id: "Key",
root: "data"
},
[{
name: "Key"
},
{
name: "Value"
}]),
baseParams: {
action: "GetCitiesByProvince"
}
}),
mode: "local",
valueField: "Key",
triggerAction: "all",
readOnly: true,
displayField: "Value",
hiddenName: "CityId",
name: "CityId",
listeners: {
select: function(combo, record, index) {
win.dealStoreWin.get(0).form.findField("CountyId").clearValue();
win.dealStoreWin.get(0).form.findField("CountyId").getStore().load({
params: {
args: record.id
}
});
}
}
},
columnWidth: .5
},
{
layout: "form",
items: {
xtype: "combo",
fieldLabel: "所在区",
width: 130,
store: new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
url: ""
}),
reader: new Ext.data.JsonReader({
id: "Key",
root: "data"
},
[{
name: "Key"
},
{
name: "Value"
}]),
baseParams: {
action: "GetCountyByCity"
}
}),
mode: "local",
valueField: "Key",
triggerAction: "all",
readOnly: true,
displayField: "Value",
hiddenName: "CountyId",
name: "CountyId"
},
columnWidth: .5
}]
}
KK3K2005 2010-06-25
  • 打赏
  • 举报
回复
ComBox.Store.Load(url)
设置里面的URL就可以刷新数据了
也就是 第一个COMBOX的选择事件后 调用后面一个ComBox.Store.Load(url) 里面的URL根据选择的值变化下
MVC的代码还是很简洁的
dragonsky_w 2010-06-25
  • 打赏
  • 举报
回复
我清楚的知道原理,可是我就是写不出来,只写出了一个省市二级联动的效果,可是,当要加入县/地区的联动时,就出现了错误……
hoojo 2010-06-22
  • 打赏
  • 举报
回复

联动就是根据第一个的值,去查询第二个的结果。然后根据第一个和第二个的值去查询第三个的结果。基本思路都这样
suland 2010-06-22
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 zoujp_xyz 的回复:]
可以用三个combo
默认省是加载所有的。
当选择了省就可以传该省id过去load市
区也一样
[/Quote]
嗯,做法和我的一样。
zoujp_xyz 2010-06-22
  • 打赏
  • 举报
回复
可以用三个combo
默认省是加载所有的。
当选择了省就可以传该省id过去load市
区也一样
suland 2010-06-22
  • 打赏
  • 举报
回复
我倒是有一个非常完整的省市县/区级联下拉菜单例子,但不是Ext的,是用jQuery写的。

52,797

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 Ajax
社区管理员
  • Ajax
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧