在jqGrid中搜索 [英] search in jqGrid
问题描述
我是jqGrid的入门者,我在ASP.NET中编写用于构建jqGrid的代码
i'm starter in jqGrid, i write this code for build jqGrid in ASP.NET
var grid = $('#list');
grid.jqGrid({
url: 'jQGridHandler.ashx',
postData: { ActionPage: 'CostTypes', Action: 'Fill' },
ajaxGridOptions: { cache: false },
direction: "rtl",
datatype: 'json',
height: 490,
colNames: ['CostId', 'CostNo', 'CostName', 'Remark '],
colModel: [
{ name: 'COST_ID', width: 100, sortable: true, search:true, editable: false,
hidden: true, key: true, index: 'COST_ID' },
{ name: 'COST_NO', width: 100, sortable: true, editable: true },
{ name: 'COST_NAME', width: 350, sortable: true, editable: true },
{ name: 'REMARK', width: 300, sortable: true, editable: true }
],
gridview: true,
rowNum: 30,
rowList: [30, 60, 90],
pager: '#pager',
sortname: 'COST_ID',
viewrecords: true,
rownumbers: true
});
grid.jqGrid('navGrid', '#pager', { add: false, edit: false, del: true, search: true },
{},
{},
{ url: "JQGridHandler.ashx?ActionPage=CostTypes&Action=Delete",
reloadAfterSubmit: false },
{ multipleSearch: true});
当单击搜索图标并在输入文本示例时显示搜索框costNo=1
jqGrid无法过滤,我认为此操作无效,请帮助我进行jqGrid的隐式搜索
谢谢大家
when click in search icon and show search box when enter text example costNo=1
jqGrid not filter i think this action no work, please help me for implimet search in jqGrid
thanks all
编辑01:当我添加loadonce: true
搜索工作时,但是删除此选项时,搜索不起作用,请帮助我.谢谢
EDIT 01: when i add loadonce: true
search work but when remove this option search don't work, please help me. thanks
推荐答案
如果使用loadonce: true
,则数据将<一次>一次加载到网格中.之后,将datatype
更改为"local"
,并且所有重装,排序,搜索(过滤)之类的操作将在本地 中实现,而无需与服务器通信.
If you use loadonce: true
the data will be loaded in the grid once. After that the datatype
will be changed to "local"
and all actions like reloading, sorting, searching (filtering) will be implemented locally without communication with the server.
如果用户开始搜索,将重新加载网格.如果使用url: 'jQGridHandler.ashx', datatype: 'json'
,则新请求将发送到URL jQGridHandler.ashx
.一些其他参数通知服务器应该过滤数据,_search
参数将设置为true
.由于使用multipleSearch: true
,有关搜索过滤器的其余信息将通过另一个参数filters
发送.这是JSON格式的字符串.该格式在文档中进行了描述.因此,服务器必须解码filters
参数并过滤网格数据(通常是根据filters
参数的值构造SELECT
SQL语句的WHERE
部分).
If the user start searching the grid will be reloaded. If you use url: 'jQGridHandler.ashx', datatype: 'json'
then the new request will be sent to the URL jQGridHandler.ashx
. Some additional parameters inform the server that the data should be filtered, the _search
parameter will be set to true
. Because you use multipleSearch: true
the rest information about the searching filter will be send in another parameter: filters
. It's a string in JSON format. The format is described in the documentation. So the server have to decode the filters
parameter and filter the grid data (typically one constructs WHERE
part of the SELECT
SQL statement based on the value of the filters
parameter).
在答案中,您将找到代码示例,并可以下载
In the answer you will find the code example and can download the demo project.
这篇关于在jqGrid中搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!