jqgrid - search toolbar

匿名 (未验证) 提交于 2019-12-03 01:40:02

问题:

The Toolbar Search demo under section 3.7 draws up the search toolbar for every column. Is it possible to have just one search toolbar that filters data across all columns and all pages?

For more info: jqGrid filtering on the client-side using "filterToolbar"

JSON

{    "mypage":{       "outerwrapper":{          "page":"1",          "total":"2",          "records":"2",          "innerwrapper":{             "rows":[                {                   "id":"1",                   "cells": [                      {                          "fieldType": "image",                          "label": "image",                          "value": "<img src=icon.gif>"                                               },                      {                          "fieldType": "number",                          "label": "number",                          "value": 100                      },                      {                         "fieldType": "string",                         "label": "string",                         "value": "James Kisnar"                      },                      {                         "fieldType": "alphanumeric",                         "label": "alphanumeric",                         "value": "77 Wall Street"                      },                      {                         "fieldType": "date",                         "label": "date",                         "value": "12/20/2011"                      },                      {                         "fieldType": "decimal",                         "label": "decimal",                         "value": "23.55"                      }                   ]                },                {                   "id":"2",                   "cells": [                      {                          "fieldType": "image",                          "label": "image",                          "value": "<img src=icon.gif>"                                               },                      {                          "fieldType": "number",                          "label": "number",                          "value": 140                      },                      {                         "fieldType": "string",                         "label": "string",                         "value": "James Kitchener"                      },                      {                         "fieldType": "alphanumeric",                         "label": "alphanumeric",                         "value": "123 ABC"                      },                      {                         "fieldType": "date",                         "label": "date",                         "value": "12/20/2011"                      },                      {                         "fieldType": "decimal",                         "label": "decimal",                         "value": "23.55"                      }                   ]                },                 {                   "id":"3",                   "cells": [                      {                          "fieldType": "image",                          "label": "image",                          "value": "<img src=icon.gif>"                                               },                      {                          "fieldType": "number",                          "label": "number",                          "value": 657                      },                      {                         "fieldType": "string",                         "label": "string",                         "value": "Loo Gatner"                      },                      {                         "fieldType": "alphanumeric",                         "label": "alphanumeric",                         "value": "123 XYZ"                      },                      {                         "fieldType": "date",                         "label": "date",                         "value": "12/20/2011"                      },                      {                         "fieldType": "decimal",                         "label": "decimal",                         "value": "23.55"                      }                   ]                },                 {                   "id":"4",                   "cells": [                      {                          "fieldType": "image",                          "label": "image",                          "value": "<img src=icon.gif>"                                               },                      {                          "fieldType": "number",                          "label": "number",                          "value": 1290                      },                      {                         "fieldType": "string",                         "label": "string",                         "value": "William Parker"                      },                      {                         "fieldType": "alphanumeric",                         "label": "alphanumeric",                         "value": "123 FGH"                      },                      {                         "fieldType": "date",                         "label": "date",                         "value": "12/20/2011"                      },                      {                         "fieldType": "decimal",                         "label": "decimal",                         "value": "23.55"                      }                   ]                }              ]          }       }    } } 

JQGrid Definition

$(function (){     var getValueByName = function (cells, cellItem) {         var i, count = cells.length, item;         for (i = 0; i < count; i += 1) {             item = cells[i];             if (item.label === cellItem) {                 return item.value;             }         }         return '';     };     $("#myjqgrid").jqGrid({         url: "jqgrid.json",         datatype: "json",         contentType: "application/x-javascript; charset=utf-8",         colNames:['Image','Number', 'String', 'Alphanumeric','Date','Decimal'],         colModel:[             {name:'image',index:'image',jsonmap:function(obj){return getValueByName(obj.cells, "image");}, width:150, align:"center"},             {name:'number',index:'number',jsonmap:function(obj){return getValueByName(obj.cells, "number");}, width:150, align:"left", sortable:true},             {name:'string',index:'string',jsonmap:function(obj){return getValueByName(obj.cells, "string");}, width:150, align:"left", sortable:true},             {name:'alphanumeric',index:'alphanumeric',jsonmap:function(obj){return getValueByName(obj.cells, "alphanumeric");}, width:200, align:"left", sortable:true},             {name:'date',index:'date',jsonmap:function(obj){return getValueByName(obj.cells, "date");}, width:150,align:"left", sortable:true},             {name:'decimal',index:'decimal',jsonmap:function(obj){return getValueByName(obj.cells, "decimal");}, width:150,align:"left", sortable:true},         ],         jsonReader: {             root: "mypage.outerwrapper.innerwrapper.rows",                       page: "mypage.outerwrapper.page",             total: "mypage.outerwrapper.total",             records: "mypage.outerwrapper.records",             repeatitems: false         },         rowNum:2,         rowList:[2, 4],         pager: '#Pager',         recordpos: 'left',         multiboxonly:true,         viewrecords: true,         sortorder: "desc",         multiselect: true,         scrolloffset: 0,             loadonce: true,              sortable: true,          sorttype: "text",         cache: true,         height: "120px"     });     $("#myjqgrid").jqGrid('navGrid','#Pager',{add:false,del:false,edit:false,position:'right'});     $("#myjqgrid").jqGrid('filterToolbar',{stringResult: true,searchOnEnter : false}); }); 
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!