Announcement

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

    Refresh data in ListGrid FilterEditor

    I am using the ListGrid filter row and often specify an optionDataSource that will display the filter options in a drop-down from a view in the database. In some cases, I know that the filter data has changed in the database but it will not be reflected in the filter drop-down unless the grid is completely re-built.

    Is there a way to refresh the data in the filter drop-down? I have tried the following:

    Code:
    // Invalidate filter drop downs
    grid.getFields().forEach((value: Isc.ListGridField, index: number, array: Isc.ListGridField[]): void => {
    
        if (value.optionDataSource) {
            isc.DataSource.getDataSource(value.optionDataSource).invalidateCache();  // Doesn't work
        }
    });
    Thanks.

    v12.1p_2020-04-23 (2020-04-23)

    #2
    That approach would work, except that you are also invalidating any other caches on the page for any other DBCs. You didn't say how it "doesn't work" but you should see requests from FormItems that have DataSources, and perhaps the data is the same for some reason.

    There are a couple of other approaches:

    1. listGrid.getFilterEditor().getEditItem().fetchData() [for a SelectItem or ComboBoxItem]

    2. listGrid.hideFilterEditor(); listGrid.showFilterEditor();

    Comment


      #3
      Hi kylemwhite,

      this answer by Isomorphic shows how to accomplish this.

      Best regards
      Blama

      Comment


        #4
        That other thread addresses a slightly different need: having a SelectItem or ComboBoxItem that always fetches every time the pickList is opened. If instead you just have a specific situation in which cache needs to be dropped, you want the approach from this thread.

        Comment


          #5
          Thanks for the quick response.

          "doesn't work" in this case means that I don't see the updated data in the filter drop-down nor do I see a request go to the server to try to fetch new data.

          For option #1, I did not find the getFilterEditor() method in the documentation.

          Option #2 is working for me although I don't see the referenced methods in the documentation (and therefore they are not available in my TypeScript library) but the following works great:

          Code:
          // Force filter editors to reload
          if (grid.showFilterEditor) {
              grid.setShowFilterEditor(false);
              grid.setShowFilterEditor(true);
          }
          Thanks.

          Comment


            #6
            Sorry, the doc references were slightly off:

            #1 it's an AutoChild, so it's actually just a field: listGrid.filterEditor

            #2 you're correct, it's a single API with a true/false flag, not separate show/hide APIs

            Comment

            Working...
            X