基于另一个下拉列填充struts2 jQuery网格下拉列 [英] populate struts2 jQuery grid dropdown column based on another dropdown column

查看:100
本文介绍了基于另一个下拉列填充struts2 jQuery网格下拉列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在发布之前,我已经搜索过这样的问题。发现的大部分答案与struts2 jQuery网格无关。这是我的情况:

I have searched for this kind of question before posting. Most of the answers found are not related to struts2 jQuery grid. Here is my situation:


  1. 我已经在初始加载时动态填充了我的下拉框。

  2. 现在我想根据其他下拉框中的选择重新加载一个下拉框。

  3. 我正在使用属性/主题寻找内置的解决方案,但是我无法找到一个。

任何人都可以共享任何解决方案?

Can anyone share any solution to this?

这是我的代码:

<sjg:gridColumn
    name="aut"
    index="aut"
    title="AUT"
    width="300"
    sortable="true"
    editable="true"
    edittype="select"
    surl="%{selectautsurl}"
    editoptions="{ dataUrl : '%{selectautsurl}' }"

   />
    <sjg:gridColumn
    name="eforms"
    index="eforms"
    title="Page/Eform"
    width="300"
    sortable="true"
    editable="true"
    edittype="select"
    surl="%{selecteformsurl}"
    editoptions="{ dataUrl : '%{selecteformsurl}' }"
    /> 

非常感谢您的帮助。

推荐答案

您需要做的是将 dataEvents 添加到第一个 gridColumn 更改值重新加载第二个 gridColumn 。你可以这样做,

What you need to do is to add dataEvents to the first gridColumn which changed value reloads the second gridColumn. You can do something like this,

<s:url id="url_id" namespace="/your_namespace" 
action="action_url_to_get_the_reloaded_list" >

    <sjg:gridColumn
        name="aut"
        index="aut"
        title="AUT"
        width="300"
        sortable="true"
        editable="true"
        edittype="select"
        surl="%{selectautsurl}"
        editoptions="{ dataUrl : '%{selectautsurl}', dataEvents: [type: 'change', fn: function(e) 
    {
                var url= '<s:property value="url_id" />' + '?your_attribute_sent_to_the_back=' + $('input#aut').val();, options;
                $.getJSON(url, function(retVal)
                {
                    options += '<option value="">&nbsp;</option>';
                    $.each(retVal.ur_returned_value, function(index, element)
                    {
                        options += '<option value="' + element.your_value + '">' + element.your_display_value + '</option>';
                    });     
                    $('input#eforms').html(options);
                });         
    }] }"

       />

不要测试这个解决方案,但我认为这样会有效。

I didn't test this solution but i think it will work.

这篇关于基于另一个下拉列填充struts2 jQuery网格下拉列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆