Announcement

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

    ListGrid "continuous grouping" when total rows changes because of filtering Best Practice

    Hi Isomorphic,

    my main ListGrid in my application is showing data grouped. Because of groupByMaxRecords this can't happen all the time.
    I'm pretty sure there is no declarative way of "keeping a ListGrid grouped if possible". I came up with this programmatic solution but am not sure if it is correct. Can you add your two cents?
    See this modified sample (v12.0p_2022-03-31) and change the filter from "XD" to "D".

    Code:
    isc.ListGrid.create({
        ID: "dsListGrid",
        width: "100%",
        height: "100%",
        autoFetchData: true,
        dataSource: "supplyItem",
        showFilterEditor: true,
        initialCriteria: {
            _constructor: "AdvancedCriteria",
            operator: "and",
            criteria: [{
                fieldName: "itemName",
                operator: "lessThan",
                value: "XD"
            }, ]
        },
        groupByField: "units",
        groupByComplete: function(fields) {
            if (fields == null || fields.length == 0) {
                isc.logWarn('Not grouped');
                this.showField("units");
                this.getFieldByName("units").canHide = true;
                isc.say("Can't group");
            } else {
                isc.logWarn('Grouped by: ' + fields)
                this.hideField("units");
                this.getFieldByName("units").canHide = false;
            }
        },
        dataArrived: function(startRow, endRow) {
            if (!this.isGrouped && (this.getGroupByFields() == null || this.getGroupByFields().length == 0) && this.data.lengthIsKnown() && this.data.getLength() <= this.groupByMaxRecords) {
                isc.logWarn('Grouping by units, as data length (' + this.data.getLength() + ') is below groupByMaxRecords');
                this.groupBy("units");
            }
        }
    });
    I'm seeing two requests on the described refilter for "D" (expected) and twice this log line:
    Grouping by units, as data length (839) is below groupByMaxRecords
    Grouping by units, as data length (839) is below groupByMaxRecords
    I'm not sure the line should be there twice, because the 2nd request is because we are already trying to group - so I kinda expect to return this.isGrouped to return true for the 2nd request. Is this a problem?
    Could you a add declarative way with a new property like "alwaysTryToGroupBy" to your enhancement list?

    Thank you & Best regards
    Blama
    Last edited by Blama; 7 Apr 2022, 00:40.

    #2
    Grouping is asynchronous, so isGrouped is not set immediately upon calling groupBy(). You could avoid calling groupBy() again until groupByComplete() fires, but the second identical request for grouping is automatically ignored anyway.

    Note this might be a weird experience. Another approach would be to use a Notify to tell the user something like: "The set of rows is now small enough to be grouped. Proceed with grouping?".

    Comment


      #3
      Hi Isomorphic,

      thanks. I was worried about this 2nd call. If that's no problem that's good. I think I'm fine with the UI experience for now, but if I was using 12.1, I'd definitely use a Notify to tell the user what's happening.
      What do you think about the idea of a new property like "alwaysTryToGroupBy"?

      Best regards
      Blama
      Last edited by Blama; 7 Apr 2022, 00:42.

      Comment


        #4
        At first glance this seems like it may not be enough of a common or frequent requirement to need a built in property, but we'll bring it bring it to the attention of the design team for consideration. If we decide to add it, we'll be sure to follow up on this thread

        Thanks for the suggestion.

        Regards
        Isomorphic Software

        Comment

        Working...
        X