免费的jqGrid搜索参数在filterToolbar中消失 [英] free jqGrid search parameter disappearing in filterToolbar
问题描述
我使用的是 freejqGrid 版本4.13.1。我刚刚添加了过滤器工具栏的代码,该代码正常工作,但搜索后搜索参数消失了。搜索工作和一切,但我想在工具栏中保留该文本,直到使用(x)清除。
I am using version 4.13.1 of freejqGrid. I just added the code for the filter toolbar, which is working, except that the search parameter disappears after the search. The search works and everything but I would like to leave that text in the toolbar until cleared using the (x).
$('#jqGrid_destroyed').jqGrid({
url:'/url.php',
height: 'auto',
shrinkToFit: true,
width: Math.floor($(window).width()*1),
datatype: 'json',
mtype: 'POST',
colNames:[
'Flat ID',
'Customer',
'Flat #',
'MiscCode',
'Item Number',
'Item Description',
'plus',
'RevDate',
'Created Date',
'Plate/Flat in QA',
'Computer Files to Waiting Destruct',
'Plates/Flat Destroyed',
'Date Confimation Sent to Customer'
],
colModel:[
{name:'flat_id',hidden:true},
{width:14,name:'Customer'},
{width:10,name:'flat_plate_num'},
{width:13,name:'MiscCode'},
{width:20,name:'item_number'},
{width:45,name:'item_description'},
{width:12,name:'plus'},
{width:16,name:'revdate'},
{width:22,name:'created_date', align: "right", hidden:true},
{width:17,name:'flat_in_qa'},
{width:20,name:'computer_files_to_waiting_destruct'},
{width:25,name:'flat_destroyed'},
{width:20,name:'date_confimation_sent_to_customer', formatter : 'date', formatoptions : {srcformat: "Y-m-d", newformat:"m/d/Y"}}
],
sortname: 'date_confimation_sent_to_customer',
sortorder: 'desc',
viewrecords: true,
gridview: true,
caption: 'Waiting Destruct',
rowNum: 10000,
pager:true,
searching: { defaultSearch: "cn" }
}).jqGrid("filterToolbar");
推荐答案
免费jqGrid 4.13.1推出新功能 - 填写基于 postData.filters
的过滤器工具栏。请参阅 README4.13.1 。该功能有一些错误,存在于您的情况下。这些错误在更高版本的免费jqGrid中得到修复。
Free jqGrid 4.13.1 introduced new feature - filling of the filter toolbar based on the postData.filters
. See the README4.13.1. The feature had some bugs, which exists in your case. The bugs are fixed in the later version of free jqGrid.
可以按使用情况关闭该功能 loadFilterDefaults:false
(通过使用 .jqGrid(filterToolbar,{loadFilterDefaults:false})
或更好地通过更改搜索:{defaultSearch:cn}
到搜索:{defaultSearch:cn,loadFilterDefaults:false}
)。另一方面,我建议你更新到当前发布的免费jqGrid版本:4.13.5或使用GitHub的最新资源。
One can switch off the feature by usage loadFilterDefaults: false
(by usage .jqGrid("filterToolbar", {loadFilterDefaults: false})
or better by changing searching: { defaultSearch: "cn" }
to searching: { defaultSearch: "cn", loadFilterDefaults: false }
). On the other side I would better recommend you to update to the current released version of free jqGrid: 4.13.5 or to use the latest sources from GitHub.
搜索选项 loadFilterDefaults:false
在许多情况下非常实用。例如,可以使用两个过滤器工具栏和搜索对话框。如果要在过滤器工具栏中设置一些过滤器,然后打开搜索对话框,则会在对话框中看到当前过滤器。您可以修改它并应用新过滤器。网格将显示新过滤器,但旧版本的jqGrid仍会在过滤器工具栏中显示旧过滤器。我发布了旧答案,其中显示了如何根据当前使用的过滤器填充过滤器工具栏。新版本的免费jqGrid将自动刷新过滤器工具栏 ,如果 filterToolbar的默认
loadFilterDefaults:true
选项使用code>。
The searching option loadFilterDefaults: false
is very practical in many scenarios. For example one can use both filter toolbar and the Searching Dialog. If you would set some filter in the filter toolbar and then opening Searching Dialog, then you will see the current filter in the dialog. You can modify it and apply the new filter. The grid will show the new filter, but the old versions of jqGrid will still display old filter in the filter toolbar. I posted the old answer, which shows how one can fill the filter toolbar based on the current used filter. The new version of free jqGrid will refresh the filter toolbar automatically if the default loadFilterDefaults: true
option of the filterToolbar
is used.
还有其他常见情况,其中 loadFilterDefaults:true
会有所帮助。例如,可以使用 loadonce:true
选项从服务器加载所有JSON数据。免费的jqGrid允许将 loadonce:true
选项与 forceClientSorting:true
结合使用,其中本地在数据显示在网格中之前,排序和过滤。它允许加载所有数据,但只显示过滤和排序的数据,并在本地分页数据。要过滤数据,只需设置过滤器
属性 postData
。按使用 filterToolbar
使用默认 loadFilterDefaults:true
选项可以看到当前应用的过滤器,这对用户有帮助。
There are other common scenarios where loadFilterDefaults: true
would be helpful. One can, for example, load all JSON data from the server using loadonce: true
option. Free jqGrid allows to combine loadonce: true
option with forceClientSorting: true
, which apply local sorting and filtering before the data will be displayed in the grid. It allows to load all the data, but display only filtered and sorted data with paging the data locally. To filter the data one need just set filters
property of postData
. By usage filterToolbar
with default loadFilterDefaults: true
option one will see the currently applied filter, which could be helpful for the user.
这篇关于免费的jqGrid搜索参数在filterToolbar中消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!