2015-10-20 53 views
0

我正在使用jqgrid版本4.5.2。以下是我的網格的定義。在列模型中,我有一個名爲region的列,其上面應用了過濾器。定製jqgrid過濾器邏輯

jq("#grid").jqGrid({  
url:finalUrl, 
ajaxGridOptions: {cache: false},//added the option to always reload the grid and not to cache the result. 
datatype: 'json',  
mtype: 'GET', 
colNames:[ 'Requestor Name'],  
colModel:[ 
    {name:'requestor',index:'requestor',sortable: true, width:100,editable:false, editrules:{required:true}, editoptions:{size:10}}, 
    {name:'requestorRegion', index:'requestorRegion',sortable: true,width:65,editable:false, editrules:{required:true}, editoptions:{size:8, style: "height: 90%"}, stype:'select', edittype:'select',"searchoptions": { 
      "value": ":All;Asia Pacific:Asia Pacific;Australia/NZ:Australia/NZ;Europe:Europe;Japan:Japan;Latin America:Latin America;North America:North America;CCEMA:CCEMA" 
     }} 
    ], 
    postData: {  
    },  
    height: 'auto',  
    autowidth: true,  
    rownumbers: true,  
    pager: '#pager',  
    viewrecords: true,  
    sortorder: "asc",  
    emptyrecords: "Empty records",  
    loadonce: true, 
    rowNum:20, 
    ignoreCase: true, 
    prmNames: { 
     nd: null 
    }, 
    loadComplete: function() { 
    }, 

    jsonReader : {  
     root: "rows",   
     repeatitems: false, 
     page:"page",   
     total: "total",   
     records: "records", 
     cell: "cell",   
     id: "id"  
     } 
    }); 

jQuery("#grid").jqGrid('navGrid','#pager',{edit:false,add:false,del:false,search: false, refresh:true}) 
    .navButtonAdd('#pager',{caption:"Export All",buttonicon:"ui-icon-document",onClickButton: function(){window.open(excelUrl,'_self');},position:"last"}); 
jQuery("#grid").jqGrid('filterToolbar', { stringResult: true, searchOnEnter: false, defaultSearch: "cn",ignoreCase: true }); 

我從篩選器中選擇歐洲地區而不是網格應過濾記錄歐洲地區的記錄。 這工作正常。但現在的要求是,如果歐洲地區被選中,那麼我應該在網格中顯示包含歐洲地區和CCEMA的所有記錄。這可能嗎?如果有可能比如何做到這一點?

注意:我使用loadonce = true一次在網格中加載數據庫中的所有記錄。

回答

0

如果我理解你的問題正確,那麼你可以嘗試選擇歐洲等組合價值「的歐洲,CCEMA:歐洲」;所以在服務器端,當您在下拉列表中選擇歐洲時,您可能會收到「歐洲,CCEMA」作爲搜索值。然後你可以用SQL「in」子句對這些值進行一些修改。

你也可以用比逗號其他字符(,)結合不同的值,但你必須設置相應的邏輯在服務器端。

試試看看是否有幫助

例如,

{name:'requestorRegion', index:'requestorRegion',sortable: true,width:65,editable:false, editrules:{required:true}, editoptions:{size:8, style: "height: 90%"}, stype:'select', edittype:'select',"searchoptions": { 
     "value": ":All;Asia Pacific:Asia Pacific;Australia/NZ:Australia/NZ;Europe,CCEMA:Europe;Japan:Japan;Latin America:Latin America;North America:North America;CCEMA:CCEMA" 
    }}