日期:2014-05-20  浏览次数:20706 次

Extjs中的comboBox从远程获取的数据无法显示的问题?
我在formpanel中定义了一个comboBox,想让它从远程加载数据,遇到的问题是远程的数据加载出来了,但是却无法显示在comboBox中的,源码如下,请各位大虾指教(将mode设置为local或直接remote都没有结果)。
1、远程数据源定义如下:
 
JScript code

var classStore=new Ext.data.Store({
        autoLoad:true,
        proxy:new Ext.data.HttpProxy({
            url:'learner/loadAllClass.action'
        }),
        reader:new Ext.data.JsonReader({
            root:'classList',
            fields:['className']
        })
    });
    classStore.load();
     

2、comboBox设置如下:
JScript code

var className=new Ext.form.ComboBox({
        id:'',
        fieldLabel:'所属团体',
        mode:'local',
        name:'person.groupName',
        hiddenName:'person.groupName',
        triggerAction:'all',
        //loadingText:'正在加载团体信息,请稍候...',
        store:classStore,
        valueField:'className',
        displayField:'className',
        forceSelection:true,
        editable:false
    })


3、后台struts.xml配置部分如下:
XML code

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "struts-2.1.dtd" >
<struts>
<package name="learner-package" namespace="/learner" extends="json-default">
<action name="load" class="learnerAction" method="load">
<result type="json">
<param name="includeProperties">{learnerList,totalRecords}</param>
</result>
</action>
<action name="uploadExcel" class="learnerAction" method="upload">
<interceptor-ref name="fileUploadStack"/>
<result type="json">
<param name="root">result</param>
<param name="contentType">text/html</param>
</result>
</action>
<action name="saveOne" class="learnerAction" method="saveOne">
<result type="json">
<param name="root">result</param>
</result>
</action>
<action name="deletes" class="learnerAction" method="deletes">
<result type="json">
<param name="root">result</param>
</result>
</action>
<action name="loadAllClass" class="learnerAction" method="loadAllClass">
<result type="json">
<param name="root">classList</param>
<param name="includeProperties">className</param>
</result>
</action>
</package>
</struts>


4、action所依赖的dao方法以及list中的对象具体内容如下:
Java code

public List getAllClass() throws DAOException{
        try{
            String queryString="from LearnerClass";
            return this.getHibernateTemplate().find(queryString);
        }
        catch(Exception ex){
            throw new DAOException(ex);
        }
        
}
public class LearnerClass implements java.io.Serializable {

    // Fields

    private String className;
    private String classDesc;
    private String classAddress;
    private String classPerson;
    private Long classTel;

    // Constructors

    /** default constructor */
    public LearnerClass() {
    }

    /** full constructor */
    public LearnerClass(String className, String classDesc,
            String classAddress, String classPerson, Long classTel) {
        this.className = className;
        this.classDesc = classDesc;
        this.classAddress = classAddress;
        this.classPerson = classPerson;
        this.classTel = classTel;
    }

    // Property accessors

    public String getClassName() {
        return this.className;
    }

    public void setClassName(String className) {
        this.className = className;
    }

    public String getClassDesc() {
        return this.classDesc;
    }

    public void setClassDesc(String classDesc) {
        this.classDesc = classDesc;
    }

    public String getClassAddress() {
        return this.classAddress;
    }

    public void setClassAddress(String classAddress) {
        this.classAddress = classAddress;
    }

    public String getClassPerson() {
        return this.classPerson;
    }

    public void setClassPerson(String classPerson) {
        this.classPerson = classPerson;
    }

    public Long getClassTel() {
        return this.classTel;
    }

    public void setClassTel(Long classTel) {
        this.classTel = classTel;
    }

}