i have grid in providing search when user highlights text want filter.
the oncellselect looks 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 have search operators have customized , using in grid:
searchoptions:{sopt:["cn",'mc','mn',"eq","ne","lt","le","gt","ge","bw","ew","nc"]} the mc , mn part of customsortoperations.
now want when user selects text inside specific cell inside grid, want detect search filter used. example default search filter cn.
i have tried this:
$("a.soptclass[data-colname='"+selectioncolumn+"']").attr('data-soper') but gives me default cn everytime.
i can text inside link give me symbolic name ~ cn, == eq with
$("a.soptclass[data-colname='"+selectioncolumn+"']").text() however there jqgrid way of rather getting exact search operator selected? i.e. cn,eq,ne,le, etc
please let me know if working demo required , update question.
update: demo.
on line 659 , 660 using callback $("a.soptclass[data-colname='"+selectioncolumn+"']").text()
in other words want selected search operator inside oncellselect
i still not full understand exact behavior want implement, seems can start oncellselect code following:
oncellselect: function(row, col, content, event) { var p = $(this).jqgrid("getgridparam"); var hdiv = p.frozencolumns === true && p.colmodel[col].frozen === true ? this.grid.fhdiv : this.grid.hdiv; var $elem = $(hdiv).find("#gs_" + $.jgrid.jqid(p.id + "_" + p.colmodel[col].name)); var oper = $elem.parent().prev().children("a").data("soper"); ... } the $elem uses standard id behavior of current free jqgrid implementation (no idmode option of filtertoolbar specified). element $elem <input> or <select> element in filter toolbar. can use $elem(selection) change value. oper variable contains chosen searching operation. 1 should use .data("soper") instead of .attr("data-soper") access data.
i hope it's missing currently.
Comments
Post a Comment