I have a grid in which I am providing search when the user highlights the text they want to filter.
The onCellSelect
looks like this:
onCellSelect: function(row, col, content, event) {
var cm = grid.jqGrid("getGridParam", "colModel");
if (window.getSelection) {
selection = window.getSelection();
} else if (document.selection) {
selection = document.selection.createRange();
}
selectionColumn = cm[col].name;
selection.toString() !== '' && $("#gs_"+selectionColumn).val(selection.toString());
console.log($("a.soptclass[data-colname='"+selectionColumn+"']").attr('data-soper'));
if(selection.toString() != '')
{
grid[0].triggerToolbar();
}
}
Now I have some search operators which I have customized and using it in the grid:
searchoptions:{sopt:["cn",'mc','mn',"eq","ne","lt","le","gt","ge","bw","ew","nc"]}
The mc
and mn
are a part of customSortOperations
.
Now what I want is when the user selects some text inside a specific cell inside a grid, I want to detect which search filter was used. For example by default the search filter is cn
.
I have tried this:
$("a.soptclass[data-colname='"+selectionColumn+"']").attr('data-soper')
but it gives me the default cn
everytime.
I can get the text inside the link which will give me a symbolic name like ~
for cn
, ==
for eq
with
$("a.soptclass[data-colname='"+selectionColumn+"']").text()
However is there a jqgrid way of rather getting the exact search operator selected? i.e. cn
,eq
,ne
,le
, etc
Please let me know if a working demo is required and I will update the question.
UPDATE: DEMO.
On line 659 and 660 I am using this callback $("a.soptclass[data-colname='"+selectionColumn+"']").text()
In other words I want the selected search operator inside onCellSelect