Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/475.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript jqGrid下拉值_Javascript_Jqgrid - Fatal编程技术网

Javascript jqGrid下拉值

Javascript jqGrid下拉值,javascript,jqgrid,Javascript,Jqgrid,我正在做一个项目,我需要根据网格中的学位筛选学生。我有一个下拉列表,它从DB加载所有学位列表,下面是图像。但问题是,默认情况下,它会选择第一个值,不像其他下拉列表,它会有默认文本,如-,请选择-,等等。是否有任何方法可以创建类似的内容。我已经使用map&list来加载下拉列表。下面是我到目前为止所做的。任何帮助都会反过来帮助我 colModel : [ {name : 'usn_number',index : 'usn_number',searchoptions: { sopt: ['eq']

我正在做一个项目,我需要根据网格中的学位筛选学生。我有一个下拉列表,它从DB加载所有学位列表,下面是图像。但问题是,默认情况下,它会选择第一个值,不像其他下拉列表,它会有默认文本,如-,请选择-,等等。是否有任何方法可以创建类似的内容。我已经使用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}
                            ],
函数getoptionList()已定义

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。我在控制器中创建了如下列表

......
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
......
。。。。。。
List locList=new ArrayList();
locList.add(新位置());//首先添加一条空白记录。您可以根据需要修改它。
locList.addAll(baseInformationService.getAllLocationsList());//添加其他列表记录
model.addAttribute(“locList”,locList);//把它放到模型上
......
希望能帮助你。

试试这个

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
        }
    }
成功:函数(数据){
options=“0:--请选择--”;
对于(var j=0;j

也希望它有帮助

k我会尝试一下并让你知道。嗨,谢谢你的回答对我有用,但必须在数据库中进行更改,就像如果你选择该选项,它不应该搜索该记录一样。