Announcement

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

    ListGridField.getRecordSummary and editing

    SmartClient Version: v10.0p_2014-10-13/EVAL Development Only (expires 2014.12.12_06.38.34) Licensed to: Isomorphic Software (#ISC_EVAL_NIGHTLY)

    Chrome on OSX

    Hello, I've just noticed that ListGridField.getRecordSummary, defined on a field of type:"summary", after editing a record, is called even on other records.
    Please modify the showcase sample #canEditFreeze like this:

    Code:
    isc.ListGrid.create({
        ID: "supplyList",
        width: 500, height: 224,
        dataSource: supplyItem, 
        autoFetchData: true,
        canEdit: true,
        fields: [
            {name: "category", width: 80},
            {name: "itemName", width: 150},
            {name: "SKU", width: 100},
            {name: "unitCost", width: 80},
            {name: "testSummary", type: "summary", width: 100,
                getRecordSummary: function (record, field) {
                    isc.logEcho("itemID", record.itemID)
                    return record.unitCost * record.unitCost;
                }
            },
            {name: "description", width: 250}
        ]
    })
    then edit a single field of a record. You'll see something like this in the developer console logs:
    Code:
    16:31:53.921:IBLR8:WARN:Log:2: "itemID"
    16:31:54.005:TMR4:WARN:Log:1: "itemID"
    16:31:54.006:TMR4:WARN:Log:2: "itemID"
    16:31:54.007:TMR4:WARN:Log:3: "itemID"
    16:31:54.009:TMR4:WARN:Log:4: "itemID"
    16:31:54.010:TMR4:WARN:Log:5: "itemID"
    16:31:54.011:TMR4:WARN:Log:6: "itemID"
    16:31:54.013:TMR4:WARN:Log:7: "itemID"
    16:31:54.019:TMR4:WARN:Log:8: "itemID"
    16:31:54.020:TMR4:WARN:Log:9: "itemID"
    16:31:54.021:TMR4:WARN:Log:10: "itemID"
    16:31:54.022:TMR4:WARN:Log:11: "itemID"
    16:31:54.023:TMR4:WARN:Log:12: "itemID"
    The first row in the log is relative to the updated record, but why is it called other 12 times?
    Last edited by claudiobosticco; 14 Oct 2014, 07:06.

    #2
    SmartClient Version: v10.0p_2014-10-13/EVAL Development Only (expires 2014.12.12_06.38.34) Licensed to: Isomorphic Software (#ISC_EVAL_NIGHTLY)

    Chrome on OSX

    Here's another test case, this one seems a bug, to me.

    Please modify the #canEditFreeze sample like this:

    Code:
    isc.ListGrid.create({
        ID: "supplyList",
        width: 700, height: 300,
        dataSource: supplyItem,
        autoFetchData: true,
        canEdit: true,
        groupByMaxRecords: 4000, groupByField: "category",
        showGridSummary: true,
        showGroupSummary: true,
        showGroupSummaryInHeader: true,
    
        fields: [
            {name: "category", width: 80},
            {name: "itemName", width: 150},
            {name: "unitCost", width: 80},
            {name: "testSummary", type: "summary", width: 100,
                showGridSummary: true, showGroupSummary: true,
                summaryFunction: ["sum"],
                getGroupSummary: function (records, field, groupNode) {
                    var tot = 0;
                    for (var i = 0; i < records.length; i++) {
                        tot += records[i].unitCost
                    }
                    return tot;
                },
                getRecordSummary: function (record, field) {
                    isc.logEcho("itemID, unitCost", record.itemID + ', ' + record.unitCost)
                    return record.unitCost * record.unitCost;
                }
            },
            {name: "description", width: 250}
        ]
    })
    then edit the unitCost field on one record. You'll get a log in the developer console like this:
    Code:
    17:09:03.803:KPR4:WARN:Log:1, 3: "itemID, unitCost"
    17:09:03.869:KPR4:WARN:Log:1, 3: "itemID, unitCost"
    17:09:04.006:XRP2:WARN:Log:1, 3: "itemID, unitCost"
    So the getRecordSummary function is called 3 times after the update.

    If I run the test case with SmartClient Version: v9.1p_2014-10-05/PowerEdition Development Only (built 2014-10-05)
    the method is called 2 times (which also seems wrong to me).

    Comment


      #3
      For issue #1, this is expected behavior as the ListGrid body of a databound ListGrid always gets redrawn for a "data change" event, such as a row edit. This is certainly something that could be optimized in future releases.

      For issue #2, the increase to 3 calls over 2 in 9.1p has been fixed (check the next nightlies), but again the two calls are part of our design. The row is redrawn immediately after the edit, and then again when the "data change" event arrives. (Note that in this case we don't rerun the function for each row because of special optimization logic connected with grouping, which is not active in case #1. So the "always" above is without grouping.)

      If you believe there are any incorrect values appearing, let us know.
      Last edited by Isomorphic; 14 Oct 2014, 17:03.

      Comment


        #4
        Actually I'm trying to make up a test case, because I think I've found a bug.

        Please modify the #canEditFreeze sample like this:
        Code:
        isc.ListGrid.create({
            ID: "supplyList",
            width: 700, height: 300,
            dataSource: supplyItem,
            autoFetchData: true,
            canEdit: true,
            groupByMaxRecords: 4000, groupByField: "category",
            showGridSummary: true,
            showGroupSummary: true,
            showGroupSummaryInHeader: true,
        
            fields: [
                {name: "category", width: 80},
                {name: "itemName", width: 150},
                {name: "unitCost", width: 80},
                {name: "testSummary", type: "summary", width: 100,
                    showGridSummary: true, showGroupSummary: true,
                    summaryFunction: ["sum"],
                    getGroupSummary: function (records, field, groupNode) {
                        var tot = 0;
                        for (var i = 0; i < records.length; i++) {
                            tot += records[i].unitCost
                        }
                        return tot;
                    },
                    getRecordSummary: function (record, field) {
                        return record.unitCost * record.unitCost;
                    }
                },
                {name: "testSummary2", type: "summary", width: 100,
                    showGridSummary: true, showGroupSummary: true,
        
                    summaryFunction: ["sum"],
                    getGroupSummary: function (records, field, groupNode) {
                        var tot = 0;
                        for (var i = 0; i < records.length; i++) {
                            tot += records[i].unitCost
                        }
                        return tot;
                    },
                    getRecordSummary: function (record, field) {
                        isc.logEcho("testSummary", record.testSummary)
                        return record.testSummary;
                    }
                },
                {name: "description", width: 250}
            ]
        })
        then edit the unitCost field. You'll see that the 'testSummary2' column doesn't get updated.

        Even a call to recalculateSummaries() has no effect.

        But if you remove the 'summaryFunction' and 'getGroupSummary' from the 'testSummary2' field definition, like this:
        Code:
        isc.ListGrid.create({
            ID: "supplyList",
            width: 700, height: 300,
            dataSource: supplyItem,
            autoFetchData: true,
            canEdit: true,
            groupByMaxRecords: 4000, groupByField: "category",
            showGridSummary: true,
            showGroupSummary: true,
            showGroupSummaryInHeader: true,
        
            fields: [
                {name: "category", width: 80},
                {name: "itemName", width: 150},
                {name: "unitCost", width: 80},
                {name: "testSummary", type: "summary", width: 100,
                    showGridSummary: true, showGroupSummary: true,
                    summaryFunction: ["sum"],
                    getGroupSummary: function (records, field, groupNode) {
                        var tot = 0;
                        for (var i = 0; i < records.length; i++) {
                            tot += records[i].unitCost
                        }
                        return tot;
                    },
                    getRecordSummary: function (record, field) {
                        return record.unitCost * record.unitCost;
                    }
                },
                {name: "testSummary2", type: "summary", width: 100,
                    showGridSummary: true, showGroupSummary: true,
                    getRecordSummary: function (record, field) {
                        isc.logEcho("testSummary", record.testSummary)
                        return record.testSummary;
                    }
                },
                {name: "description", width: 250}
            ]
        })
        and then edit the unitCost field, this time you'll see that the 'testSummary2' column does get updated.

        Please note: my actual use case is a little different: my 'testSummary' field isn't of type 'summary' but is a customSQL field which is calculated server side based on values of other fields.
        Last edited by claudiobosticco; 26 Nov 2014, 03:02.

        Comment


          #5
          SmartClient Version: v10.0p_2015-01-14/EVAL Development Only (expires 2015.03.15_10.24.32) Licensed to: Isomorphic Software (#ISC_EVAL_NIGHTLY)

          This problem (first test case of previous post) is still there.
          Is it actually a bug or i'm doing something not supported?

          Comment


            #6
            When you figure out a way to reproduce an issue and create a test case, be sure to do this as a new reply. When you add this information to an existing post, there is no notification and it is easily missed.

            We'll take a look at the new test case.

            Comment


              #7
              We don't currently support one "summary" type field depending on another. That's why you see that when the value of testSummary2 is calculated, it uses the value of testSummary from the previous calculation pass. We intend to provide an official way to do this in future releases the product, but for now you'll need code around it.

              Some options are:
              - write all of your calculations as functions of non-summary fields only
              - when one of your custom summary field functions runs, cache the result yourself somewhere (the grid?) so that it's available to you in other summary field functions.

              Comment


                #8
                ok, thanks for the clarification.

                Comment

                Working...
                X