Announcement

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

    Calendar triggers fetch even when autoFetchData is not set

    SmartClient Version: v13.1p_2025-05-03/Enterprise Deployment (built 2025-05-03)

    Hello, I just noticed that the Calendar performs a fetch automatically, even though autoFetchData has not been set.

    This also happens in the showcase, in the databoundCalendar sample, if you remove autoFetchData.

    In my application, where the dataSource is not clientOnly as in the databoundCalendar sample, the call stack is as follows:

    Code:
        [c]RPCManager.sendRequest(request=>Obj)
        DataSource.performSCServerOperation(dsRequest=>Obj, data=>Obj{_constructor:AdvancedCriteria})
        DataSource.sendDSRequest(dsRequest=>Obj)
        DataSource.performDSOperation(operationType=>"fetch", data=>Obj{_constructor:AdvancedCriteria}, callback=>Obj, requestProperties=>Obj)
        DataSource.fetchData(criteria=>Obj{_constructor:AdvancedCriteria}, callback=>Obj, requestProperties=>Obj)
        ResultSet.fetchRemoteData(serverCriteria=>Obj{_constructor:AdvancedCriteria}, startRow=>undef, endRow=>undef)
        ResultSet._fetchAllRemoteData()
        ResultSet.getRange(start=>0, end=>1, ignoreCache=>undef, fetchNow=>undef)
        ResultSet.get(pos=>0)
        Canvas.requestVisibleRows()
        Canvas.filterWithCriteria(criteria=>Obj{_constructor:AdvancedCriteria}, operation=>Obj{ID:SCUOLA_CALCIO_PLANNING_ATTIVITA_fetch}, context=>Obj)
        Canvas._filter(type=>"fetch", criteria=>Obj{_constructor:AdvancedCriteria}, callback=>undef, requestProperties=>Obj)
        Class.invokeSuper(clazz=>null, methodName=>"_filter", a=>undef, b=>undef, c=>undef, d=>undef, e=>undef, f=>undef, g=>undef, h=>undef, i=>undef, j=>undef, lastArg=>undef)
        Class.Super(methodName=>"_filter", args=>[object Arguments], nativeArguments=>undef)
        Calendar._filter(type=>"fetch", criteria=>undef, callback=>undef, requestProperties=>Obj, doneSaving=>undef)
        Canvas.fetchData(criteria=>undef, callback=>undef, requestProperties=>undef)
        CalendarView._refreshData()
        CalendarView.refreshEvents(caller=>"draw")
        callback()
        [c]Class.fireCallback(callback=>callback(), argNames=>null, args=>null, target=>null, catchErrors=>true)
        [c]Timer._fireTimeout(ID=>"_timeout39", tmrID=>757, delayedTmrID=>undef)
        anonymous()
            "isc.Timer._fireTimeout(ID, tmrID);"

    #2
    hi Claudio,

    Yes, Calendars don't really support auto-fetching in the usual way - in fact, if you set autoFetchData, the current Calendar code will clear it at init.

    The fetch isn't being kicked off by initial draw, per se - it's a result of the date-range changing when includeRangeCriteria is true.

    We'll consider whether we need to change this behavior, or perhaps update the doc for Calendar.autoFetchData, and get back to you.

    Comment


      #3
      Hello, in my use case, I have a custom SQL query (using Velocity) for the Calendar. I need to wait for the result of another fetch in order to include some attributes in the Calendar's fetch.

      But the Calendar performs an initial fetch (which returns zero records because it lacks the attributes required by the Velocity code). Then, if I call fetchData with the correct criteria, Calendar.willFetchData() returns false, so it doesn't fetch again.

      Comment


        #4
        Thanks for the detail - we've fixed up Calendar.autoFetchData so it works like other DBCs - false will now prevent the fetch on initial draw and you can call fetchData() yourself or change the date-range in the widget to cause an automatic fetch.

        Please retest with today's builds dated May 6 or a later one.

        Comment


          #5
          Note that, if you do want your custom criteria to be included in the autoFetchData fetch, you can override calendar.adjustCriteria(defaultCrit).

          Comment


            #6
            SmartClient Version: v13.1p_2025-05-06/Enterprise Deployment (built 2025-05-06)

            Hello, actually when Calendar.currentViewName: "month" (which is my case), the initial fetch is still performed. It seems to occur at line 5359 of the debug version of ISC_Calendar:
            Code:
            // call filterData() on the Calendar to refetch
            if (!cal.hasData()) cal.fetchData();
            Nice addition with the Calendar.adjustCriteria() override, thanks (Not documented yet, by the way).

            Comment


              #7
              Thanks Claudio - yes, we noticed the monthView issue already - long-standing logic meant that there actually wasn't a way to draw the MonthView without event-data, because the events are part of the grid-cell in that view, so data has always been fetched blindly on draw.

              We've already re-wired things this morning so that autoFetchData: false works the same in MonthView as in other views.

              You should find the fixes in today's builds.

              And we'll expose adjustCriteria(), which is doc'd but with @vis internal

              Comment


                #8
                Hello, I've just tried it and it's working now - thank you very much!

                I just have one remaining doubt: I noticed that if I call calendar.fetchData() and then animateShow(), the fetch doesn't happen. But if I call animateShow() first and then fetchData(), it works.
                Is this the expected behavior?

                Please note: this seems related to the scenario where you previously fixed an issue: https://forums.smartclient.com/forum...606#post273606

                Comment


                  #9
                  hi Claudio - we've fixed initial fetch in databound Calendars when fetchData() is called before draw() and drawing happens as a result of animateShow(). The fetch is performed as a result of draw() on animation start, meaning clean on-screen behavior / no visual delay in rendering the events after animation - we'll add some autotests for the issues in this thread as well.

                  We also exposed adjustCriteria().

                  Please retest with a new build, dated May 8 or later.
                  Last edited by Isomorphic; 7 May 2025, 21:50.

                  Comment


                    #10
                    SmartClient Version: v13.1p_2025-05-08/Enterprise Deployment (built 2025-05-08)

                    Hi, I just tested the latest build, but I don't see the fetch - maybe I need to wait for tomorrow's build.

                    Comment


                      #11
                      We see things working as described in 13.1 here, if you use this code:

                      Code:
                      isc.Calendar.create({
                          ID: "eventCalendar",
                          startDate: eventData.getDataStartDate(),
                          dataSource: eventDS
                      , currentViewName: "month"
                      , autoFetchData: false
                      , autoDraw: false
                      });
                      Run the sample, change to the browser console and run eventCalendar.fetchData() followed by eventCalendar.animateShow() - the fetchData() call is delayed until animateShow() draw()s the widget, as detailed previously, but it does run at that time. Subsequent direct calls to fetchData() won't perform a fetch because the criteria hasn't changed.

                      If you still see a problem in your project code, please provide sample code that reproduces it.



                      Comment


                        #12
                        Hello, using your example I see that even if I don't call fetchData() but only call animateShow(), a fetch still happens after animateShow().

                        Also, I noticed that if I modify the example code to include
                        eventCalendar.animateShow(), the Calendar is actually not displayed (whereas it does get displayed if I use isc.Timer.setTimeout("eventCalendar.animateShow()")).

                        BTW, my use case is more similar to this, which uses a SQL DataSource:
                        Code:
                        isc.Calendar.create({
                            ID:"aCalendar",
                            width: "100%",
                            height: "100%",
                            autoFetchData: false,
                            dataSource: "supplyItem",
                            autoDraw:false,
                            currentViewName:"month",
                            startDateField:"nextShipment" ,
                            implicitCriteria:{_constructor:"AdvancedCriteria", operator:"and",criteria:[{fieldName:"nextShipment", operator:"notNull"}]}
                        });
                        
                        aCalendar.fetchData();
                        aCalendar.animateShow();
                        However, when testing this in the showcase, I get different behaviour that I can't explain. If I run it from the showcase's source editor, the Calendar is not displayed. But if I run it from the browser console, it does appear, but the fetch is executed even if I remove the aCalendar.fetchData(); line.

                        Is there still some anomaly, or am I missing something?

                        Comment

                        Working...
                        X