1

I'm familiar with the custom operations that can bd added to the dropdown selection on the left next to each column filter.

What i'm after, is to add two new types of custom operators for filtering: 1. Empty 2. Not empty

While I know how to achieve that per se, I have a problem with the UX of such flow within Free JqGrid. This is because these two custom operators don't need any input from the user once they were chosen, so the user will have to click 'enter' after choosing this operator with an empty value - very confusing.

What I want to know is how to achive the following consider I already defined a new custom operator:

  1. Make the transaction go once I choose this operator, without waiting for the user to type anything, or click enter (something like onSelect).
  2. Optionally, disable the ability to type anything within that specific filter once that specific operator was selected.

Thanks,

Tal.

Tal
  • 391
  • 2
  • 11

1 Answers1

3

Thanks for pointing of the problem of definition custom unary operations. I committed the changes of the code of free jqGrid to allow to specify the custom unary operations inside of new option customUnaryOperations.

The demo defines two custom filtering operations: "em" ("is empty") and "nm" ("isn't empty") and use the operations in "Amount" and "Notes" columns. The column "Notes" uses additionally the standard (predefined) "nu" ("is null") and "nn" ("is not null") operations. The column "amount" uses

searchoptions: {sopt: ["eq", "ne", "em", "nm"]}

and the column "note" uses

searchoptions: {sopt: ["cn", "bw", "ew", "eq", "bn", "nc", "en", "nu", "nn", "em", "nm"]}

additionally the demo uses customSortOperations and new customUnaryOperations:

customUnaryOperations: ["em", "nm"],
customSortOperations: {
    em: {
        operand: "=''",
        text: "is empty",
        filter: function (options) {
            var v = options.item[options.cmName];
            if (v === undefined || v === "") {
                return true;
            }
        }
    },
    nm: {
        operand: "!=''",
        text: "isn't empty",
        filter: function (options) {
            var v = options.item[options.cmName];
            if (v !== undefined && v !== "") {
                return true;
            }
        }
    }
}
Oleg
  • 220,925
  • 34
  • 403
  • 798
  • Hi Oleg, The X at the right of the column, is not working when using Unary operations. I suppose it's because of the fact there is no value to reset, and so the user is not getting any reaction as a result of clicking on the X. The only way to get out of this mode is to select a different op, and then click on the X. – Tal Jan 04 '17 at 18:25
  • @Tal: I think you are right. It would be helpful to reset search operation to default one (searchoptions.sopt[0] or o.defaultSearch) on click on "X" if the current operation is an Unary operation. I will make the changes in the code of free jqGrid and will inform you to refresh your free jqGrid. I have to do some other things now, but I post you comment later. – Oleg Jan 04 '17 at 18:52
  • @Tal: I committed [the corresponding changes](https://github.com/free-jqgrid/jqGrid/commit/a6e0aa1b8d83a77155c6e10c1e5758c22a238be9) to GitHub. Please reload free jqGrid, which you use and test the behavior of "X" now. By the way [the demo](http://www.ok-soft-gmbh.com/jqGrid/OK/formEditOnDoubleClick-jqueryui-fa3-customUnaryOperations.htm) loads jqGrid from GitHub, thus you can use it for festing of the latest changes, which I made. – Oleg Jan 04 '17 at 21:02
  • Thanks a lot. Works well. – Tal Jan 05 '17 at 15:53