如何在重新加载JQGrid表后保留搜索文本

时间:2014-07-15 13:00:03

标签: jquery jqgrid

每次我加载JQGrid表时,我在顶部添加一个'div',用于在Table内搜索(已在stackoverflow中发布的解决方案):

$('#t_' + $.jgrid.jqID($grid[0].id))
.append($("<div><label for=\"globalSearchText\">Global search in grid for:&nbsp;" +
    "</label><input id=\"globalSearchText\" type=\"text\"></input>&nbsp;" +
    "<button id=\"globalSearch\" type=\"button\">Search</button></div>"));

搜索效果很好。问题是,如果加载页面,搜索Área将变空。有没有办法在加载页面后保留SearchText?

1 个答案:

答案 0 :(得分:0)

You can use cookies for doing same.

See code below.
<script>

$( document ).ready(function(){

       $("#gs_Customer").blur(function(){
            var searchVal = $("#gs_Customer").val();
            alert(searchVal);
            //here you can set javascript cookies
       });

        $("#gs_Customer").val(searchVal); // Here you can get search text value from cookies. 
}); 
</script>