followmephoe
20 Sep 2007, 7:03 PM
var fs = new Ext.form.Form({
labelAlign: 'left',
url:'123'
});
var store = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
url: 'createHao'
}),
reader: new Ext.data.JsonReader({
root: 'rs',
totalProperty: 'cs',
id: 'hid'
}, Plant)
});
var Plant = Ext.data.Record.create([
{name: 'hid', mapping: 'hid'},
{name: 'hname', mapping:'hname'}
]);
new Ext.form.ComboBox({
fieldLabel:'所属地区',
store: store,
hiddenName:'city',
displayField:'hname',
typeAhead: true,
valueField:'hid',
mode: 'remote',
triggerAction: 'all',
emptyText:'请选择一个地区',
selectOnFocus:true,
msgTarget:'under',
allowBlank:false,
forceSelection:true,
resizable:true
})
String hql="from Hao s where 1=1";
Vo.HaoDAO dao=new HaoDAO();
Session session = dao.getSession();
Transaction tr = session.beginTransaction();
java.util.List list=dao.getList(hql);
int totalcount=dao.totalcount(hql);
tr.commit();
session.clear();
session.close();
StringBuilder builder=new StringBuilder();
org.json.JSONObject obj=new JSONObject();
org.json.JSONArray array=new JSONArray();
try {
obj.put("cs",totalcount);
for(int i=0;i<list.size();i++){
org.json.JSONObject obj1=new JSONObject();
Vo.Hao p=(Vo.Hao)list.get(i);
obj1.put("hid",p.getId());
obj1.put("hname", p.getName());
array.put(obj1);
obj.put("rs", array);
}
} catch (JSONException e) {
e.printStackTrace();
}
builder.append(obj);
System.out.print(builder.toString());
response.getWriter().print(builder.toString());
print {"cs":2,"rs":[{"hname":"java","hid":1},{"hname":"C","hid":2}]}
no data in the combox,what is wrong?
labelAlign: 'left',
url:'123'
});
var store = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
url: 'createHao'
}),
reader: new Ext.data.JsonReader({
root: 'rs',
totalProperty: 'cs',
id: 'hid'
}, Plant)
});
var Plant = Ext.data.Record.create([
{name: 'hid', mapping: 'hid'},
{name: 'hname', mapping:'hname'}
]);
new Ext.form.ComboBox({
fieldLabel:'所属地区',
store: store,
hiddenName:'city',
displayField:'hname',
typeAhead: true,
valueField:'hid',
mode: 'remote',
triggerAction: 'all',
emptyText:'请选择一个地区',
selectOnFocus:true,
msgTarget:'under',
allowBlank:false,
forceSelection:true,
resizable:true
})
String hql="from Hao s where 1=1";
Vo.HaoDAO dao=new HaoDAO();
Session session = dao.getSession();
Transaction tr = session.beginTransaction();
java.util.List list=dao.getList(hql);
int totalcount=dao.totalcount(hql);
tr.commit();
session.clear();
session.close();
StringBuilder builder=new StringBuilder();
org.json.JSONObject obj=new JSONObject();
org.json.JSONArray array=new JSONArray();
try {
obj.put("cs",totalcount);
for(int i=0;i<list.size();i++){
org.json.JSONObject obj1=new JSONObject();
Vo.Hao p=(Vo.Hao)list.get(i);
obj1.put("hid",p.getId());
obj1.put("hname", p.getName());
array.put(obj1);
obj.put("rs", array);
}
} catch (JSONException e) {
e.printStackTrace();
}
builder.append(obj);
System.out.print(builder.toString());
response.getWriter().print(builder.toString());
print {"cs":2,"rs":[{"hname":"java","hid":1},{"hname":"C","hid":2}]}
no data in the combox,what is wrong?