0

我想实现一个依赖下拉列表(eq. A 取决于 B)。在进行表单编辑时,对话框显示的时候,B 无法知道 A 的选定值,因此 B 无法更新其 dataurl。

任何身体都可以帮忙吗?

4

1 回答 1

0

您对此有任何了解吗?如果没有,我遇到了同样的问题并已解决。可能对您没有用,但对其他人有用。

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
 <HEAD>
  <TITLE> New Document </TITLE>
  <META NAME="Generator" CONTENT="EditPlus">
  <META NAME="Author" CONTENT="">
  <META NAME="Keywords" CONTENT="">
  <META NAME="Description" CONTENT="">
 </HEAD>

<script>


    grid.jqGrid({
        data: mydata,
        datatype: 'local',
      ondblClickRow: function(rowid) {
        jQuery(this).jqGrid('editGridRow', rowid,
                            {recreateForm:true,closeAfterEdit:true,
                               closeOnEscape:true,reloadAfterSubmit:false});
       },
        colModel: [
            { name: 'Name', w 200 },
            { name: 'Country', width: 100, editable: true, formatter: 'select',
                edittype: 'select', editoptions: {
                    value: <someStaticOrDynamicValues>,                     
                    },
                    dataEvents: [
                        {
                            type: 'change',
                            fn: function(e) {
                                changeStateSelect(e);
                            }
                        }
                    ]
                }
            },
            {
                name: 'State', width: 100, editable: true, formatter: 'select',
                edittype: 'select', editoptions: { value: states }
            }
        ],      

    });

    function changeStateSelect(e){
            var countryId = $(e.target).val();
            $.ajax({
                url:"getStateList.html?countryId="+countryId,
                type: "post",
                success:function(newOptions){
                    var form = $(e.target).closest("form.FormGrid");
                    $("select#State.FormElement",form[0]).html(newOptions);
                }
            });
        }
</script>
 <BODY>

 </BODY>
</HTML>

JAVA中的一些地方

   @RequestMapping(value = "/getStateList.html", method = RequestMethod.POST)
    public @ResponseBody String getSuperVisorList(@RequestParam("countryId") String countryId) throws Exception {

        StringBuffer select = new StringBuffer("<select>");
        select.append("<option value=''>  </option>");
        for (int i =0; i<10; i++) {
            select.append("<option value='" 
                        + i
                        + "'>" + "youValues" + "</option>");
        }
        select.append("</select>");
        return select.toString();
    }
于 2014-04-18T08:26:00.983 回答