【问题标题】:Get selected value in the formatter of select in Struts 2 jQuery grid在 Struts 2 jQuery 网格中的 select 格式化程序中获取选定的值
【发布时间】:2014-07-17 07:57:33
【问题描述】:

这是我的 Struts 2 网格列:

<sjg:gridColumn name="interview_notif" index="interview_notif" title="Interview Notification" editable="true" sortable="false" formatter="IntrvNot"/> 

这是我使用的格式化程序:

function IntrvNot(value, options, rowObject){
 var radioHtml = '<select><option value="1">Yes</option><option value="2">No</option></select>';         
 return radioHtml;

格式化程序创建一个包含两个选项的选择,但它不选择数组中的那个。

当网格填充时,如何将选定的值设置为数据库(数组)中的值?

【问题讨论】:

  • 你想被选中什么?
  • 下拉列表中的值应选择为arraylist中的值

标签: java jquery jsp struts2 jqgrid


【解决方案1】:

下拉列表中的值应选择为arraylist中的值

提供选项映射而不是数组列表

function IntrvNot(value, options, rowObject){
    var option = {1:"Yes", 2: "No"};
    var radioHtml = '<select>';
    $.each(option, function(key, val){
        radioHtml+='<option value="'+key+'"'+(key==value?' selected="selected"':'')+'>'+val+'</option>';
    });
    radioHtml+='</select>';
    return radioHtml;
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-08-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多