javascript - How to make the "jqGrid toolbar search" search for the at in any occurrence, not just the beginning -
i've implemented jqgrid toolbar search enabled on it. problem search working '%search_criteria' (only matching beginning) need '%search_criteria%' (any occurrence in column value).
e.g: grid has column "class" values: math-101, , math-102 if searched for: "101" ==> 0 matches. have search whole word "math-101".
i saw example working wont, , not different grid @ all, , don't how working on example below , not on mine!!! ex: http://www.ok-soft-gmbh.com/jqgrid/simplelocalgridwithsearchingtoolbar.htm
my grid:
var data = [[1, "math-101", "oc", "intel", "09-02-15", "09-30-15", "a", 120, "general", 200]] $("#grid").jqgrid({ datatype: "local", height: 200, colnames:['#','class','loc','type','start dt','end dt','section','dur','gen/priv','fee'], colmodel: [ {name: 'scheduleid', index: 'scheduleid', width: 30}, {name: 'classname', index: 'classname', width: 60}, {name: 'location', index: 'location', width: 60}, {name: 'classtype', index: 'classtype', width: 60}, {name: 'startdt', index: 'startdt', width: 60, sorttype: "date", searchoptions:{datainit:function(el){$(el).datepicker({dateformat:'yy-mm-dd'});} }}, {name: 'enddt', index: 'enddt', width: 60, sorttype: "date", searchoptions:{datainit:function(el){$(el).datepicker({dateformat:'yy-mm-dd'});} }}, {name: 'section', index: 'section', width: 60}, {name: 'duration', index: 'duration', width: 60}, {name: 'scheduletype', index: 'scheduletype',width: 60}, {name: 'fee', index: 'fee', width: 60, formatter:'number', align:'right'} ], pager: '#pager', rownum: 10, rowlist: [10, 20, 30], rownumbers: true, sortname: "class", sortorder: "desc", viewrecords: true, gridview: true, ignorecase: true, autoencode: true, autowidth: true, expandcolclick: true, caption: "schedule list" }); var names = ['scheduleid', 'classname', 'location', 'classtype', 'startdt', 'enddt', 'section', 'duration', 'scheduletype', 'fee', 'ceu', 'status', 'ifee', 'tcost', 'fcost', 'mcost', 'omcost']; var mydata = []; (var = 0; < data.length; i++) { mydata[i] = {}; (var j = 0; j < data[i].length; j++) { mydata[i][names[j]] = data[i][j]; } } (var = 0; <= mydata.length; i++) { $("#grid").jqgrid('addrowdata', + 1, mydata[i]); } $("#grid").jqgrid('filtertoolbar', { stringresult: true, searchoperators: false, searchonenter: false, autosearch: true, defaulysearch: "cn" });
thanks help.
you should replace defaulysearch: "cn"
defaultsearch: "cn"
. should fix main searching problem. should consider use ignorecase: true
option of jqgrid force jqgrid uses case insensitive searching.
additionally strictly recommend don't use addrowdata
in loop filling of jqgrid. instead of should move code fill grid data mydata
before creating grid , use option data: mydata
. create data filled data. first page sorted data displayed. jqgrid sort data before displayed.
small additional remarks: should fix sortname: "class"
sortname: "classname"
. recommend remove index
values colmodel
. can consider use cmtemplate: { width: 60 }
option (see the answer) changes default value of property width
in colmodel
150 60. after can remove width: 60
colmodel
. recommend add sorttype: 'number'
column uses formatter:'number'
. fix sorting in column. can consider define template
2 columns contains dates (see the answer).
Comments
Post a Comment