【问题标题】:Struts2 jquery jqgrid dynamic drop list while grid editStruts2 jquery jqgrid在网格编辑时动态下拉列表
【发布时间】:2015-01-20 07:03:15
【问题描述】:

这是我的jsp代码。

<s:url id="myEditOptions" action="myEditOptions.action"/>
<sjg:gridColumn name="branch" align="left" index="Branch" id="bnch" title="Branch" 
    editable="true" onclick="" edittype="select" editoptions="%{myEditOptions}"  />

struts.xml 代码

<action name="myEditOptions" class="com.example.action.BranchAction" method="getDynamicBranch">
    <result name="success" type="json" ></result>
</action>

此处为动作类代码

public class BranchAction implements Action {

    private Map<String, String> branchList = new LinkedHashMap<String, String>();
    List<Customer> customerList;
    private List<String> brnch;
    Struts2ExampleDAO exampleDao ;
    private String myEditOptions;
    public BranchAction() {
        exampleDao = new Struts2ExampleDAOImpl();
        customerList = new ArrayList<Customer>();
    }

    public String getDynamicBranch(){       
        customerList = exampleDao.getCustomerListData();
        brnch = new ArrayList<String>();
        for(Customer cust:customerList) {
            int i=0;
            if(cust.getBranch() != null && cust.getBranch().length() !=0) {             
                brnch.add(""+i+":"+cust.getBranch());
            }
            i++;

        }
        //Collections.sort(brnch);
        myEditOptions = "{value:'"+StringUtils.join(brnch,";")+"'}";
        System.out.println("************List size:::********"+brnch.size());
        return "success";
    }


    public String getMyEditOptions() {
        return myEditOptions;
    }

    public void setMyEditOptions(String myEditOptions) {
        this.myEditOptions = myEditOptions;
    }
}

分支下拉列表未显示。如果有人知道,请帮助我在使用 struts2 jquery jqgrid 进行网格编辑时获取动态下拉列表。即使我可以通过使用普通的 struts2 选择选项来获得动态下拉列表

<s:select label="What's your favor search engine" 
    headerKey="-1" headerValue="Select Search Engines"
    list="searchEngine" 
    name="yourSearchEngine" />

像这样我在执行 struts2 网格编辑选择选项时需要相同的功能(动态下拉列表)

【问题讨论】:

    标签: jquery struts2 jqgrid grid


    【解决方案1】:

    哎呀!是的,终于在使用 struts2 jquery jqgrid 编辑网格时获得了动态下拉列表的解决方案,并且现在进行了以下更改。!

    public String getDynamicBranch(){       
        customerList = exampleDao.getCustomerListData();
        myEditOptions = "<select>";
        for(Customer cust:customerList){
            if(cust.getBranch() != null && cust.getBranch().length() !=0) {
                System.out.println("******Branch values***:::"+cust.getBranch());
                myEditOptions += "<option value="+cust.getBranch()+">"+cust.getBranch();
            }
    
        }
        myEditOptions += "<select>";
        //Collections.sort(branchList);     
        return "success";
    }
    

    【讨论】:

      猜你喜欢
      • 2014-03-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-14
      • 2016-10-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多