Announcement

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

  • Isomorphic
    replied
    Hi Blama
    There are a few things to consider here
    - There's an automatic "pre fetch" for Selectitems/ComboBoxItems by default, meaning they will fetch optionDataSource results before you show the pickList. You can turn this off via "autoFetchData:false"
    - By default items bound to the same optionDataSource will share their data sets to avoid multiple fetches. You can turn this off via 'cachePickListResults:false'
    - Once a fetch has occurred and the pickList is populated, hiding and then re-showing the pickList will not issue another fetch. You can explicitly call various APIs including "fetchData()" on a selectItem to force the cached data set to be dropped and a new fetch issued. So to force a new fetch each time the pickList is shown, you could override 'showPicker'.

    Here's a sample demonstrating this with 4 items (2 CBIs, 2 SIs) bound to the same datasource, with the same criteria. Each time you show any of the pickLists you should see a fetch occur.
    (In some cases you can get 2 fetches, this is due to a drawing/resizing behavior whereby a window of 75 rows is retrieved from the server, and then a second request is issued for the subsequent 75 rows. It should be safe to ignore)

    Regards
    Isomorphic Software

    Code:
    <isomorphic:loadDS ID="supplyItem"/>
    
    // Form 1 - one SelectItem, one ComboBoxItem
    
    // Form 2 - one SelectItem, one ComboBoxItem
    // Bound to the same data Sources / same criteria
    // We want to force a new fetch
    // - for each item when the PL is first shown
    // - for each time the PL is shown via a show-picker click within an item
    
    isc.defineClass("SelectItemAlwaysFetch", "SelectItem").addProperties({
        // Avoid sharing results with other items
        cachePickListResults:false,
        // Don't fetch until the PL is first shown
        autoFetchData:false,
        // Invalidate any cache/ Force a new fetch on every "showPicker"
        showPicker : function () {
            if (this.pickList && this.pickList.data.lengthIsKnown()) this.fetchData();
            return this.Super("showPicker", arguments);
        }
    });
    isc.defineClass("ComboBoxItemAlwaysFetch", "ComboBoxItem").addProperties({
        // Avoid sharing results with other items
        cachePickListResults:false,
        // Don't fetch until the PL is first shown
        autoFetchData:false,
        // Invalidate any cache/ Force a new fetch on every "showPicker"
        showPicker : function () {
            if (this.pickList && this.pickList.data.lengthIsKnown()) this.fetchData();
            return this.Super("showPicker", arguments);
        }
    });
    
    isc.VStack.create({
        autoDraw:true,
        membersMargin:10,
        members:[
            isc.DynamicForm.create({
                ID:"form1",
                items:[
                    {editorType:"SelectItemAlwaysFetch", name:"item1",
                     optionDataSource:supplyItem,
                     valueField:"itemName",
                     pickListCriteria:{ _constructor:"AdvancedCriteria", fieldName:"itemID", operator:"lessThan", value: 4000 }
                    },
                    {editorType:"ComboBoxItemAlwaysFetch", name:"item2",
                     optionDataSource:supplyItem,
                     valueField:"itemName",
                     pickListCriteria:{ _constructor:"AdvancedCriteria", fieldName:"itemID", operator:"lessThan", value: 4000 }
                    }
    
                ]
    
            }),
            isc.DynamicForm.create({
                ID:"form2",
                items:[
                    {editorType:"SelectItemAlwaysFetch", name:"item1",
                     optionDataSource:supplyItem,
                     valueField:"itemName",
                     pickListCriteria:{ _constructor:"AdvancedCriteria", fieldName:"itemID", operator:"lessThan", value: 4000 }
                    },
                    {editorType:"ComboBoxItemAlwaysFetch", name:"item2",
                     optionDataSource:supplyItem,
                     valueField:"itemName",
                     pickListCriteria:{ _constructor:"AdvancedCriteria", fieldName:"itemID", operator:"lessThan", value: 4000 }
                    }
    
                ]
            }),
            isc.DynamicForm.create({
                ID:"serverFetchLog",
                items:[
                    {editorType:"StaticTextItem", name:"fetchCount", value:0}
                ]
            })
        ]
    });
    
    serverFetchLog.observe(
        supplyItem, "transformRequest",
        "observer.setValue('fetchCount', (observer.getValue('fetchCount') + 1))"
    );
    ----
    Edit:
    Note: If you're working in SmartGWT you'd want to use addPickerIconClickHandler() to call fetchData() [and there'd be no need to call "Super", of course]
    Last edited by Isomorphic; 4 May 2020, 16:40.

    Leave a comment:


  • Blama
    replied
    Hi Isomorphic,

    do you have a hint on this one?

    Thank you & Best regards
    Blama

    Leave a comment:


  • Blama
    replied
    Hi Isomorphic,

    this is more about ComboBoxItem / SelectItem. ListGrid is only there to test this more easy (I thought) as pickList is a ListGrid as well.
    In ComboBoxItem it's the latter, "drop the cache each time the pickList is initially opened".

    Best regards
    Blama

    Leave a comment:


  • Isomorphic
    replied
    Can you clarify what you're trying to do here? You didn't say why you wouldn't use invalidateCache() or not use refreshData(), so we can't tell what you need.

    Also, for the parallel use case of a ComboBoxItem, are you trying to make it so that every time the criteria is changed, that's a server fetch, or do you just want to drop the cache each time the pickList is initially opened?

    Leave a comment:


  • 12.0p ListGrid enforcing request on fetchData() (without using invalidateCache())

    Hi Isomorphic,

    preparing this testcase I stumbled upon a problem I have in my application as well (although with SelectItems / ComboBoxItems pickList) and not with normal ListGrid use.

    How do I here (this modified sample, v12.0p_2020-04-16) enforce that on every click on fetchData() a fetch is issued in the Developer Console's RPC Tab?
    I think I enabled this already with useClientFiltering: false and reapplyUnchangedLocalFilter: true.

    Same for the SelectItems / ComboBoxItems pickList: How would I enforce a fetch here everytime a new SelectItem is generated (or better: the pickList is shown)?
    I assume this must somehow be related to ResultSet properties, but I did not find a matching method there.

    Thank you & Best regards
    Blama

    Code:
    isc.ListGrid.create({
        ID: "supplyItemList",
        width:"80%", height:"100%", alternateRecordStyles:true,
        dataFetchMode: "basic",
        dataSource: supplyItem,
        autoFetchData: true,
        showFilterEditor: true,
        dataProperties: { useClientFiltering: false, reapplyUnchangedLocalFilter: true },
        implicitCriteria: {
            _constructor:"AdvancedCriteria",
            operator:"and",
            criteria:[ { fieldName:"itemID", operator:"lessThan", value: 4000 } ]}
    });
    
    isc.Button.create({
       ID: "fetchDataButton",
       title: "fetchData()",
       click: function () { supplyItemList.fetchData(null, null,
            { showPrompt: true,
              promptDelay: 0,
              promptStyle: "dialog",
              prompt: "Fetching data, please wait"}
        );}
    });
    
    isc.VLayout.create({
       members: [supplyItemList, fetchDataButton],
       membersMargin: 10,
       width:"80%",
       height:"100%"
    });
Working...
X