【问题标题】:Is there a way to use jqGrid advanced search without using jqGrid?有没有办法在不使用 jqGrid 的情况下使用 jqGrid 高级搜索?
【发布时间】:2012-07-25 20:36:43
【问题描述】:

有没有不使用jqGrid而使用jqGrid高级搜索的方法?

我的意思是,我有一个ul 列表,我想使用 jqGrid 的这个惊人的高级搜索。

我想我可以有一个按钮,它可以打开高级搜索窗口,然后执行 ajax 发布。所以我可以使用 javascript 处理 json 结果来更新我的 ul。

这可能吗?

【问题讨论】:

  • 你能给我们看一个ul的例子吗?是否有必要执行 ajax 发布?或者你可以在服务器端做这一切吗?
  • ul 不相关。我想使用 jqGrid 的高级搜索实现,而不使用 jqGrid。
  • 高级搜索是指您可以在搜索/复杂搜索部分的trirand.com/blog/jqgrid/jqgrid.html 看到的选项。

标签: jquery search jqgrid


【解决方案1】:

这样的事情怎么样?这是更容易看到的小提琴: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');   
});

});
});​

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-03-11
    • 1970-01-01
    • 1970-01-01
    • 2012-05-20
    • 2016-01-10
    • 2016-01-19
    • 1970-01-01
    • 2010-11-11
    相关资源
    最近更新 更多