Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    grid filterEditor cell with isNull filterOperator and formatValue method

    SmartClient Version: v11.0p_2016-04-26/EVAL Development Only (expires 2016.06.25_09.26.45) Licensed to: Isomorphic Software (#ISC_EVAL_NIGHTLY)

    Chrome on OSX

    Hello, I've got a custom filterEditor on a ListGridField which users need to filter only for notNull, where I've defined a formatValue function which displays an icon (without text).

    With SmartClient 11, the icon disappear after the filtering.

    I managed to create a test case, similar to my use case.
    Please modify the #filter sample like this:

    Code:
    isc.ListGrid.create({
        ID: "countryList",
        width: 500, height: 224, alternateRecordStyles: true,
        dataSource: worldDS, autoFetchData: true,
        fields: [
            {name: "countryCode", title: "Flag", width: 50, type: "image", imageURLPrefix: "flags/16/", imageURLSuffix: ".png"},
            {
                name: "countryName", title: "Country",
                filterOperator: "isNull",
                filterEditorType: "select",
                filterEditorValueMap: {'United States': 'US'},
                filterEditorProperties: {
                    formatValue: function (value, record, form, item) {
                        if (value == 'US') {
                            return form.imgHTML("flags/16/US.png");
                        }
                    }
                }
            },
            {name: "capital", title: "Capital", showIf: "false"},
            {name: "continent", title: "Continent"}
        ],
        canReorderFields: true, showFilterEditor: true, filterOnKeypress: true
    })
    and the filter by countryName, selecting the only available option. You'll see that the icon appears in the filterEditor cell after selecting the option, and then disappears.
    Also, if you try to select the empty option, no filtering happens.

    This was working with 10.1, for example try this same test case with:
    SmartClient Version: v10.1p_2016-04-30/Enterprise Development Only (built 2016-04-30)

    #2
    We're not sure what you're actually trying to do, here - it doesn't really make sense to have a value picker for an "isNull" operator - what you're *actually* doing, is assigning a value to a formItem that is set to use a filterOperator which does not support values (an isNull criterion has just fieldName and operator).

    So, t's nothing to do with a value formatter - it's that, when the criterion is round-tripped, it is re-applied to the item via setCriterion(), which calls setValue(undefined), because the crit has no value.

    It might be worth taking a step back and clarifying what you actually want to do - this sees like a pretty bizarre flow to be trying to create.

    Comment


      #3
      In my actual use case, I've got a field which may be null, and when it's not null I've got only an icon displayed in the grid.
      I need to be able to filter for notNull, and previously I was displaying the icon in the FormItem filter when doing this.

      Comment


        #4
        That's not much clearer, unfortunately.

        To reiterate - an isNull or notNull criteria does not support a value - therefore, your formatter would never be called with a value - it is still called, but you have a condition that checks for a specific value - that will always fail following a round-trip, because as we just said, value is always undefined for criterion based on these valueless operators.

        Tthat's correct behavior.

        Again, it might help to *clearly* define what you want to do.

        Comment


          #5
          The user needs to filter for 'is not null', like you could do using 'inline operator filter'.
          But I don't want to enable allowFilterOperators.

          Maybe must I try to define a custom field on the dataSource which will have two actual values, one for null and another for notNull?

          Comment


            #6
            Right - so, do you *always* want to enforce not null for that field? That is, can the user change it?

            Comment


              #7
              At draw there's no filter for that field. Than the user can change it, to enforce not null.

              Comment


                #8
                Ok - as-is, the isNull crit in your sample will always be enforced, whether the user interacts with it or not, because you set a default filterOperator - just try clicking the filter button right after draw.

                If you want to be initially un-filtered on that field, remove your filterOperator from it - then, if you want a user to select from isNull and notNull, put those values in the valueMap and add a changed() handler that updates item.operator accordingly - then, in your formatter, check item.operator rather than checking the value.

                Comment

                Working...
                X