簡體   English   中英

jqGrid下拉值

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM