目前我有一个枚举:
enum LocationCodes{
USA(3), Canada(4), Carribean(5), USPacific(6)
NANPCodeGroup(int value) {this.value = value}
private final int value
public int value() {return value}
}
我的gsp中有一个jquery网格,有一个用于搜索的下拉列表
<!-- table tag will hold our grid -->
<table id="customer_list" class="scroll jqTable" cellpadding="0" cellspacing="0"></table>
<!-- pager will hold our paginator -->
<div id="customer_list_pager" class="scroll" style="text-align:center;"></div>
<script type="text/javascript">
/* when the page has finished loading.. execute the follow */
$(document).ready(function () {
jQuery("#customer_list").jqGrid({
url:'jq_customer_list',
datatype: "json",
colNames:['customer','location','id'],
colModel:[
{name:'customer'},
{name:'location',stype:'select', searchoptions:{value:':All;USA:USA;Canada:Canada;Carribean:Carribean;USPacific:USPacific;'}},
{name:'id', hidden:true}
],
rowNum:2,
rowList:[1,2,3,4],
pager: jQuery('#customer_list_pager'),
viewrecords: true,
gridview: true
});
$("#customer_list").jqGrid('filterToolbar',{autosearch:true});
});
</script>
对于我想要放入枚举值的位置。有什么想法吗?谢谢!
答案 0 :(得分:1)
这应该给出由';'
分隔的枚举列表${LocationCodes?.values()?.collect{it.toString() + ':' + it.toString()}?.join(';')}
所以你可以尝试这样的事情:
searchoptions: {
value: ":All;${LocationCodes?.values()?.collect{it.toString() + ':' + it.toString()}?.join(';')}"
}
仔细检查引号的转义,但它应该有效。 :)
答案 1 :(得分:0)
这有用吗? (假设它是GSP)
{ name:'location',
stype:'select',
searchoptions:{ value:'":All;${LocationCodes.values().collect { "$it:${it.value()}" }.join(';')};"'}},
应该给你
':All;USA:3,Canada:4,Carribean:5,USPacific:6;'
但我没有测试过: - /