2012-07-25 31 views
1

有沒有辦法使用jqGrid高級搜索而不使用jqGrid?有沒有辦法使用jqGrid高級搜索而不使用jqGrid?

我的意思是,我有一個ul列表,我想用這個驚人的高級搜索由jqGrid。

我想我可以有一個按鈕,打開高級搜索窗口,然後執行ajax帖子。所以我可以使用JavaScript來處理json結果來更新我的ul。

這可能嗎?

+0

你能告訴我們一個ul的例子嗎?是否有必要執行ajax文章?或者你可以做到所有的服務器端? – jeschafe 2012-07-25 20:57:57

+0

ul不相關。我想使用jqGrid的高級搜索實現,而不使用jqGrid。 – iuristona 2012-07-25 21:18:26

+0

通過高級搜索我的意思是你可以在http://trirand.com/blog/jqgrid/jqgrid.html搜索/複雜搜索部分看到的選項。 – iuristona 2012-07-25 21:19:25

回答

0

這樣的事情呢?這裏的小提琴更容易看到:DEMO

$(function(){ 
$('#search').dialog({width:'400px',buttons:{"Search":function(){$(this).find('input').keyup();}}}); 
$('#search').find('input').on('keyup',function(){ 
    console.log('selectValue:' + $('select').val()); 
    var lis = $('#searchMe').find('li'); 
    var inputVal = $(this).val(); 
    lis.each(function(){ 
     console.log(inputVal + ' : ' + $(this).html()); 
    var match = false; 
    switch ($('select').val()){ 
     case '0': 
      if($(this).html()==inputVal) 
       match=true; 
      break; 
     case '1': 
      if($(this).html().indexOf(inputVal)>=0) 
       match=true; 
      break; 
     case '2': 
      if($(this).html().indexOf(inputVal)==0) 
       match=true; 
      break; 
     case '3': 
      if($(this).html().indexOf(inputVal)==$(this).html().length-inputVal.length) 
       match=true;  
    } 
    if (inputVal.length==0) 
     match = true 
    if (inputVal.length>$(this).html().length) 
     match = false 
    if (match) 
     $(this).removeClass('hidden'); 
    else 
     $(this).addClass('hidden'); 
}); 

}); 
});​