JqGrid toolbar column search operator

I am using the jqGrid Filter toolbar. I am testing it for 2 columns, one numeric and another alphanumeric.

All operations with the filter through the filter toolbar are performed using the "bw" operator (starts with).

How to configure the operation I want to perform using a column?

In this case, I want to use "eq" in the numeric column and "cn" in alphanumeric format.

btw, if I use the advanced search dialog, everything works correctly.

Thanks!

Here is my implementation:

$('#EntityListGrid').jqGrid({ url: '<%= ResolveUrl("~/Controls/EntityManager/Controllers/EntitiesController.ashx?method=GridDataList") %>', datatype: 'json', mtype: 'GET', colNames: ['ID', 'Name', 'Actions'], colModel: [ { name: 'EntityID', index: 'EntityID', width: 50, align: 'left', resizable: true, sortable: true, sopt:['eq'] }, { name: 'Name', index: 'Name', width: 250, align: 'left', resizable: true, sortable: true }, { name: 'act', index: 'act', width: 75, sortable: false, search: false }, ], pager: $('#EntityListGridPager'), rowNum: 10, rowList: [10, 20, 30], sortname: 'EntityID', sortorder: 'desc', viewrecords: true, imgpath: '', caption: 'Entities', width: EntityListGridWidth, height: 400, gridComplete: function () { var ids = jQuery("#EntityListGrid").jqGrid('getDataIDs'); var editImageUrl = '<%=Page.ResolveUrl("~/Controls/EntityManager/Images/edititem.GIF")%>'; for (var i = 0; i < ids.length; i++) { var cl = ids[i]; ce = "<img src='" + editImageUrl + "' onclick='EditEntity(" + cl + "); return false;' />"; ce2 = "<input type='button' value='details' src='" + editImageUrl + "' onclick='EditEntity(" + cl + "); return false;' />"; $("#EntityListGrid").setRowData(ids[i], { act: ce2 }); } } }).navGrid('#EntityListGridPager', { search: true, edit: false, add: false, del: false, searchtext: "Search" }, {}, {}, {}, { closeOnEscape: true, multipleSearch: true, closeAfterSearch: true }); $('#EntityListGrid').jqGrid('filterToolbar', { stringResult: true, searchOnEnter: false }); 
+4
source share
2 answers

you can use the sopt property in the corresponding column definition. It could be sopt:['eq'] and sopt:['cn'] in your case. This option will overwrite the search statement only for the selected column.

Using the sopt:['eq'] property is really required. For example, if you have a column with the stype:'select', edittype:'select', formatter:'select' option stype:'select', edittype:'select', formatter:'select' .

UPDATED: Correctly configured searchoptions:{sopt: ['eq']} , not sopt: ['eq'] . Read the documentation about this.

+7
source

Just to mention, if you don't want to lose other search operands in the footer, find its importance to add all the other operands to the array. only the first is used for Toolbarsearch

for phpgrid

 $opsmeta = array("cn","eq","bw","ni","in","ne","lt","le","gt","ge","bn","ew","en","nc") ; $col["searchoptions"] = array("sopt"=>$opsmeta); 

Thanks, this helped me sort out some of the search issues.

0
source

Source: https://habr.com/ru/post/1338520/


All Articles