Announcement

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

    12.1p+ client side filterRow SelectItem aggregation question

    Hi Isomorphic,

    creating this testcase today I wondered about the (expected) duplicated entries in the "Government"-SelectItem and came up with this solution here in this modified sample (SNAPSHOT_v13.1d_2024-06-06, but basically all versions):

    With the "Government"-SelectItem as it is one only has every entry once, thanks to the groupBy, which is great.
    You can also see in the RPC-Tab that government is the only field that is returned (of course necessary for a groupBy).
    But when you select an entry and open the SelectItem again, a different entry is selected (here "British crown dependency").
    I assume this is due to pk being the primaryKey field and pk missing in the data. So it makes sense that it is this way right now and is no bug in my opinion.
    But would there be a way to make this problem go away clientSide? Perhaps by transparently creating another clientOnly DataSource with government as primaryKey?

    Also, is this really the only way to set the requestProperties? This seems awfully deep nested. Is there no (fetch-)properties on SelectItem- or ListGrid level?
    ListGrid has saveRequestProperties, but no "normal" (fetch-)RequestProperties.

    Best regards
    Blama


    Code:
    isc.ListGrid.create({
        ID: "filterGrid",
        width: 850,
        height: 500,
        alternateRecordStyles: true,
        dataSource: worldDS,
        autoFetchData: true,
        groupByField: "continent",
        groupStartOpen: "all",
        sortField: "continent",
        groupByMaxRecords: 190,
        showFilterEditor: true,
        sortByGroupFirst: "true",
        implicitCriteria: {
            _constructor: "AdvancedCriteria",
            operator: "and",
            criteria: [{
                fieldName: "continent",
                operator: "inSet",
                value: ["Africa", "Asia", "Australia/Oceania", "Europe", "North America", "South America"]
            }]
        },
        fields: [{
            name: "countryCode",
            width: 60
        }, {
            name: "countryName",
        }, {
            name: "government",
            filterEditorProperties: {
                type: "SelectItem",
                sortField: "government",
                multiple: true,
                pickListProperties: {
                    dataProperties: {
                        requestProperties: {
                            groupBy: "government"
                        }
                    }
                }
            },
        }, {
            name: "continent",
        }, {
            name: "capital"
        }]
    });
    
    // Implicit criteria Buttons
    isc.IButton.create({
        ID: "europeAsiaBtn",
        width: 250,
    
        title: "inSet: AF/AS/AU/EU/NA/SA (=all)",
        click: function() {
            filterGrid.setImplicitCriteria({
                _constructor: "AdvancedCriteria",
                operator: "and",
                criteria: [{
                    fieldName: "continent",
                    operator: "inSet",
                    value: ["Africa", "Asia", "Australia/Oceania", "Europe", "North America", "South America"]
                }]
            });
        }
    });
    isc.IButton.create({
        ID: "europeAsiaAusBtn",
        width: 250,
    
        title: "inSet: AS/AU/EU/NA/SA",
        click: function() {
            filterGrid.setImplicitCriteria({
                _constructor: "AdvancedCriteria",
                operator: "and",
                criteria: [{
                    fieldName: "continent",
                    operator: "inSet",
                    value: ["Asia", "Australia/Oceania", "Europe", "North America", "South America"]
                }]
            });
        }
    });
    isc.IButton.create({
        ID: "allCtnBtn",
        width: 250,
    
        title: "All continents (null criteria)",
        click: function() {
            filterGrid.setImplicitCriteria(null);
        }
    });
    isc.HStack.create({
        ID: "criteriaBtnStack",
        membersMargin: 30,
        height: 1,
        members: [
            isc.Label.create({
                contents: "Implicit Criteria:",
                height: 1
            }), europeAsiaBtn, europeAsiaAusBtn, allCtnBtn
        ]
    });
    
    isc.VStack.create({
        membersMargin: 30,
        members: [
            criteriaBtnStack, filterGrid
        ]
    });

    #2
    No way, it is working like this with summaryFunctions:

    Code:
    filterEditorProperties: {
                type: "SelectItem",
                sortField: "government",
                multiple: true,
                pickListProperties: {
                    dataProperties: {
                        requestProperties: {
                            groupBy: "government",
                            summaryFunctions: {"pk": "min"}
                        }
                    }
                }
            }
    That is pretty cool!
    I remember you somewhere in a thread saying that you have to replicate all server DataSource-features clientside for clientOnly-DataSources, but this is really really advanced!

    Best regards
    Blama

    Comment


      #3
      Just to connect threads - what you're doing here is pretty much a partial reinvention of SetFilterItem, which is what you should probably use instead. It handles many more cases and is extremely efficient - it can, for example, automatically derive the values from the loaded data, if the cache is complete.

      Comment


        #4
        Hi Isomorphic,

        OK, will do so eventually. This was just testing.
        Out of interest: How does the SetFilterItem deal with the problem of the missing PK (that happens with a simply groupBy without summaryFunctions)?

        Best regards
        Blama

        Comment


          #5
          Not sure what this means. You seem to be thinking of SelectItems, where a PK is required. SetFilterItem is a different component and does not require a PK to be present in the results.

          Comment


            #6
            Hi Isomorphic,

            yes, that is what I meant. Not needing a PK explains it.

            Thank you & Best regards
            Blama

            Comment

            Working...
            X