Announcement

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

    error with grid.implicitCriteria which uses a valuePath

    SmartClient Version: v13.0p_2023-06-12/AllModules Development Only (built 2023-06-12)

    Chrome on OSX

    Hello, please try this test case:

    Code:
    isc.DynamicForm.create({
        ID: "aForm",
        fields: [
            {
                name: "category",
                optionDataSource: "supplyItem",
                displayField: "category",
                valueField: "category",
                editorType: "SelectItem"
            }
        ]
    })
    
    isc.ListGrid.create({
        ID: "supplyList",
        top: 100,
        width: 500, height: 300, alternateRecordStyles: true,
        implicitCriteria: {
            _constructor: "AdvancedCriteria",
            operator: "and",
            criteria: [
                {fieldName: "category", operator: "equals", valuePath: "aForm.values.category"}
            ]
        },
        dataSource: supplyItem,
        fields: [
            {name: "SKU"},
            {name: "itemName"},
            {name: "description"},
            {name: "category"}
        ],
        showFilterEditor: true,
        filterOnKeypress: true,
        fetchDelay: 500
    });
    I get this error.

    Code:
    18:39:46.418:TMR2:WARN:Log:TypeError: Cannot read properties of undefined (reading 'fetchMode')
    Stack from error.stack:
        Canvas.refreshData(<no args: exited>) on[ListGrid ID:supplyList] @ ISC_Core.js:4894:183
        _3.<anonymous>(<no args: exited>) on[ListGrid ID:supplyList] @ ISC_Grids.js:3429:40
        _3.observation(<no args: exited>) on [FeatureExplorer ID:featureExplorer] @ ISC_Core.js:367:394
        Canvas.fireRuleContextChanged(<no args: exited>) on [DynamicForm ID:aForm] @ ISC_Core.js:4302:1279
        Canvas._provideRuleContext(<no args: exited>) on [DynamicForm ID:aForm] @ ISC_Core.js:4298:54
        Canvas.provideRuleContext(<no args: exited>) on [DynamicForm ID:aForm] @ ISC_Core.js:4286:6
        DynamicForm._delayedSetValues(<no args: exited>) on [DynamicForm ID:aForm] @ ISC_Forms.js:593:275
        [c]Page.handleEvent(<no args: exited>) on [Class Page] @ ISC_Core.js:2178:72
        EventHandler._handleIdle(<no args: exited>) on [Class EventHandler] @ ISC_Core.js:2631:769
        [c]Class.fireCallback(_1=>Obj, _2=>null, _3=>null, _4=>null, _5=>true) on [Class Timer] @ ISC_Core.js:330:252
        Timer._fireTimeout(_1=>"$ir142", _2=>157, _3=>undef) on [Class Timer] @ ISC_Core.js:2163:6
        null.<anonymous>() @ ISC_Core.js:2159:40
    Am I doing something wrong, or is it a framework bug?

    #2
    I must say that I stumbled into this while trying to make a test case for another problem, where an implicit criteria seems to be ignored by a TreeGrid.
    So, before trying to replicate it, I want to ask: is it supported setting a implicitCriteria on a TreeGrid?

    Comment


      #3
      I'd prefer to use the above pattern, but I've tried it after noticing that a usage similar to this:
      https://forums.smartclient.com/forum...ed-by-treegrid
      stopped to work in my application, after updating the SmartClient version.

      Comment


        #4
        This is likely the same regression as noted in your other thread. We'll confirm and let you know when fixes hit builds.

        Comment


          #5
          hi claudio ,

          In your test-case, you should see things start to work if you set autoFetchData: true on your grid (or otherwise fetch it), and then put your grid and form inside a mutual parent, like a Layout. Then changes to the formItem will filter the grid accordingly.

          Comment


            #6
            adding autoFetchData to the test case seems to do the trick, but:

            1. I see this in the dev console (is it a problem?):
            WARN:refreshData:supplyList:A fetch for this component is currently pending, please try again later.
            2. I see an initial fetch with criteria:
            Code:
            data:{
                    operator:"and",
                    criteria:[
                        {
                            fieldName:"category",
                            operator:"equals",
                            valuePath:"aForm.values.category",
                            value:null
                        }
                    ]
                },
            isn't it possible to avoid this first fetch?

            Also, I have attempted to add an initial value for the selectItem, both using form.values:{} and defaultToFirstOption. However, it does not seem to be used in the criteria for the initial fetch. On the other hand, if I use item.defaultValue, it is applied to the first fetch, which I think it's nice.
            I am not sure if I am overcomplicating things, but to me, this appears to be nice usage of implicitCriteria, so I'm experimenting with different options.

            ps: you're tagging another person who has my same name ;-)

            Comment


              #7
              hi claudiobosticco ;)

              We've fixed the original crash you reported, which was caused by the ruleScope attempting to refreshData() before any data had been fetched - so you can get rid of the autoFetchData setting as of tomorrow's builds, dated June 16 and later.

              Please retest and let us know if you still see that warning about pending fetches - we're not seeing it.

              Comment


                #8
                SmartClient Version: v13.0p_2023-06-16/AllModules Development Only (built 2023-06-16)

                Hello, I can confirm that I don't see javascript errors, and neither I see the warning, thanks.

                So the test case is basically working.

                The only thing I still see are a duplicated criterion in the criteria, ie:

                Code:
                {
                    dataSource:"supplyItem",
                    operationType:"fetch",
                    componentId:"supplyList",
                    data:{
                        operator:"and",
                        criteria:[
                            {
                                fieldName:"category",
                                operator:"equals",
                                valuePath:"aForm.values.category",
                                value:"Pastes and Gum"
                            },
                            {
                                fieldName:"category",
                                operator:"equals",
                                valuePath:"aForm.values.category",
                                value:"Pastes and Gum"
                            }
                        ]
                    },
                ...
                and also that first fetch, before selecting an item in the form:

                Code:
                {
                    dataSource:"supplyItem",
                    operationType:"fetch",
                    componentId:"supplyList",
                    data:{
                        operator:"and",
                        criteria:[
                            {
                                fieldName:"category",
                                operator:"equals",
                                valuePath:"aForm.values.category",
                                value:null
                            }
                        ]
                    },
                ...
                which doesn't disappear even if I use setImplicitCriteria(criteria, null, false).

                Also, is it normal that if I try selectItem.defaultToFirstOption:true, or form.values:{category:"Batteries"}, those are ignored for the first fetch?

                Comment


                  #9
                  Hello, did you have a chance to look at the last little issue of the duplicated criterion?

                  Comment


                    #10
                    We do see the duplicated criterion when fetching, and we're taking a look - we'll update here when we have more information on that and your other comments.

                    Comment


                      #11
                      hi Claudio,

                      We've fixed the duplicate implicitCriteria issue for tomorrow's builds, dated July 6 and later.

                      Retesting your other comments (defaultToFirstOption/defaultValue and form.values not working initially) - we see all of these work as expected, although they *do* happen in a second fetch, after the initial one with a null value.

                      We're looking into preventing that initial fetch - the grid is implicitly bound to that formItem, and it has no value at creation time, when ruleScope binding first takes place.

                      We'll update here when we have more information about that.

                      Comment


                        #12
                        In fact, that initial fetch is being caused by components redrawing. To fix it, just mark your components autoDraw: false, so they aren't cleared and redrawn when added to their parent. Note also that your initial sample code needs the components to be inside a layout in order for it to work at all.
                        Last edited by Isomorphic; 5 Jul 2023, 01:15.

                        Comment


                          #13
                          v13.0p_2023-07-23/AllModules Development Only
                          Chrome on MacOS

                          Hello, I've modified the original test case to use a Layout and autoDraw:false for its members:

                          Code:
                          isc.VLayout.create({
                              members: [
                                  isc.DynamicForm.create({
                                      ID: "aForm", autoDraw: false,
                                      fields: [
                                          {
                                              name: "category",
                                              optionDataSource: "supplyItem",
                                              displayField: "category",
                                              valueField: "category",
                                              editorType: "SelectItem"
                                          }
                                      ]
                                  }),
                                  isc.ListGrid.create({
                                      ID: "supplyList", autoDraw: false,
                                      width: 500, height: 300, alternateRecordStyles: true,
                                      implicitCriteria: {
                                          _constructor: "AdvancedCriteria",
                                          operator: "and",
                                          criteria: [
                                              {fieldName: "category", operator: "equals", valuePath: "aForm.values.category"}
                                          ]
                                      },
                                      dataSource: supplyItem,
                                      fields: [
                                          {name: "SKU"},
                                          {name: "itemName"},
                                          {name: "description"},
                                          {name: "category"}
                                      ],
                                      showFilterEditor: true,
                                      filterOnKeypress: true,
                                      fetchDelay: 500
                                  })
                              ]
                          })
                          The duplicate criterion is gone, thanks for the fix.

                          But the initial fetch is still there.
                          If I select a value in the formItem, and then switch to the js code tab and click "Try it" again, I actually see a couple of those initial fetch, but maybe it's a showcase "thing".

                          Also, I don't see defaultToFirstOption/defaultValue/values working, I just see that initial fetch with null value in the criterion.

                          I'm trying the test case in the online showcase https://www-demos.smartclient.com/sm...&skin=Twilight


                          Comment


                            #14
                            This looks like a potential timing issue in the RuleScope subsystem, which is magnified in the Showcase - outside of the showcase, we see values: { category: "Batteries" } working as expected, and defaultToFirstOption also working as expected. Item.defaultValue seems to only work on occasion. We'll take another look at that part and get back to you.

                            Note, though, that we do see values: { category: "Batteries" } on the form working as expected in the Showcases.

                            Comment


                              #15
                              Hi @all,

                              wow, that's cool. I never looked at RuleScope, even though I saw it mentioned here before. With it, samples like comboFormDependentSelectsDatabound could become even more declarative.

                              Best regards
                              Blama

                              Comment

                              Working...
                              X