After reading the jqGrid wiki (and taking example from: Case insensitive search in jqGrid including hidden fields), I cannot find what I want to do.
Is there any search option to enable a search anywhere in a column (automatically wildcarded).
If the column contains "Apple Iphone" I would be able to find it by using the search "iphone".
The SQL equivalent would be select * from table where lower(columnX) like '%iphone%';
Since you use toolbar searching the solution of your problem seems to be simple. You should:
- include
ignoreCase:true
to the jqGrid parameters
- include
defaultSearch:'cn'
option to the call of filterToolbar. For example: $("#list").jqGrid('filterToolbar', {defaultSearch:'cn'})
.
- If you use any select elements in the searching toolbar (
stype:'select'
) you should include in the list of searchoptions
the sopt
options which begin with 'eq': stype:'select', searchoptions: {sopt:['eq','ne']}
for example.
$("#list").jqGrid('filterToolbar', {stringResult: true, searchOnEnter: false, defaultSearch : "cn"});
In the above example the **defaultSearch : "cn"**
is used to search using any substring of item you want to search. Removing defaultSearch : "cn"
starts search beginning with the substring.
$(document).ready(function() {
colNamesData = [ 'Description']
{name:'description',index:'description', width:130, sorttype:"text", search:true, editable:true, edittype:"textarea", editoptions: {rows:"5",cols:"25",maxlength:"255"}, stype:'text', searchoptions:{sopt:['cn', 'nc', 'bw', 'bn', 'ew', 'en']}},
$("#description_table").jqGrid({
datatype: "local",
height: "auto",
autowidth: true,
ignoreCase: true,
colNames: colNamesData,
colModel: colModelHash,
pager: '#pager',
rowNum:10,
rowList:[10,25,50,100],
sortname: 'date',
sortorder: 'desc',
viewrecords: true,
editurl:"/url_name.json",
caption: 'Description'
data:<%= raw @jqgrid_table.to_json %>
});
jQuery("#description_table").jqGrid('navGrid','#pager',{del:false,add:true,edit:false},{}, {modal: true,afterSubmit:processAddEdit,recreateForm:true, afterComplete:reloadJqGrid}, {modal: true}, {multipleSearch:true});
Now if your text contains "here i go" and if you search "go", it will surely search, it works for me.
Give a try and reply if it doesn't.