[英]JQGrid - Drop down value not set correctly when edittype = 'select'
[英]jqGrid Drop Down Value
我正在某个项目中,需要根据网格中的学位过滤学生。 我有一个下拉列表,它从数据库加载所有学位列表,下面是图像 。 但是问题是默认情况下它会选择第一个值,这与其他下拉菜单不同,会出现默认文本,如--Please Select--等。有什么方法可以创建类似的东西。我已经使用map&list加载了下拉菜单。以下是我到目前为止所做的。 任何帮助都会反过来帮助我。
colModel : [ {name : 'usn_number',index : 'usn_number',searchoptions: { sopt: ['eq'] },width : 20},
{name : 'first_name',index : 'first_name',searchoptions: { sopt: ['eq'] },width : 35},
{name : 'course',index : 'course',width : 20,stype: 'select',searchoptions:{value:getOptionsList(),
sopt:['eq']}},
{name : 'semester_name',index : 'semester_name',search:false,width : 20},
{name : 'address',index : 'address',search:false,width : 30},
{name : 'mobile_number',index : 'mobile_number',search:false,width : 20},
{name : 'id',index : 'id',align : "center",sortable : false,search:false,align : 'center',
width : 15,formatter : controlFmatter}
],
函数getOptionsList()已定义,
function getOptionsList(){
$.ajax({
type: "POST",
url:'loadDegreeList',
async:false,
dataType: 'json',
success: function(data){
options=data.degreeListMap;
},
failure :function(xhr,status,msg) {
alert("Unexpected error occured. !!!"+msg);
}
});
return options;
}
谢谢
我正在使用SpringFramework。 我是这样在Controller中创建List的。
......
List<Locations> locList = new ArrayList<Locations>();
locList.add(new Locations()); // Add a Blank RecordFirst. You can modify it as you want.
locList.addAll(baseInformationService.getAllLocationsList()); // Add other list records
model.addAttribute("locList", locList); // put it to the model
......
希望可以帮到您。
尝试这个
success: function(data){
options = "0:--Please Select--";
for ( var j = 0; j < data.list.length; j++) {//Your List where those values is stored
var records = data.list[j];
options += ";"+records.ID+":"+ records.name ;// ID is primary key of that column & name is your degrees list
}
}
也看到这个希望对你有帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.