Announcement

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

    ListGrid.refreshData doesn't trigger dataChanged

    SmartClient Version: SNAPSHOT_v12.1d_2019-03-27/AllModules Development Only (built 2019-03-27)
    and
    SmartClient Version: v11.1p_2019-03-27/AllModules Development Only (built 2019-03-27)

    Hello, I've just noticed that ListGrid.refreshData doesn't trigger dataChanged, you may try this modified sample (id=gridComponents):

    Code:
    isc.ToolStrip.create({
        ID: "gridEditControls",
        width: "100%", height:24, 
        members: [
            isc.Label.create({
                padding:5,
                ID:"totalsLabel"
            }),
            isc.LayoutSpacer.create({ width:"*" }),
            isc.ToolStripButton.create({
                title:"Refresh Data",
                click: "countryList.refreshData()"
            })
        ]
    });
    
    isc.ListGrid.create({
        ID: "countryList",
        width:500, height:425, alternateRecordStyles:true,
        dataSource: countryDS,
        fields:[
            {name:"countryCode", title:"Code", width:50},
            {name:"countryName", title:"Country"},
            {name:"capital", title:"Capital"},
            {name:"continent", title:"Continent"}
        ],
        autoFetchData: true,
        showFilterEditor: true,
        canEdit:true,
        editEvent:"none",
        gridComponents:["header", "filterEditor", "body", gridEditControls],
        dataChanged : function () {
            isc.logEcho('dataChanged')
            this.Super("dataChanged", arguments);
            var totalRows = this.data.getLength();
            if (totalRows > 0 && this.data.lengthIsKnown()) {
                totalsLabel.setContents(totalRows + " Records");
            } else {
                totalsLabel.setContents(" ");
            }
        }
    })
    If you press 'refresh data' you'll see that 'dataChanged' isn't logged.

    Is it by design? Reading the dataChanged docs it seems that it would be called even in this case.

    #2
    Yes, this is by design. You can use the callback of refreshData if you want a notification.

    Comment


      #3
      Thanks, maybe a note in the documentation which specifies that in the case of refreshData it isn't called, would be useful, as a simple implementation like that sample taken from the showcase (which I've used extensively in my applications) seems broken if one uses refreshData.

      Comment


        #4
        We've added a note about dataChanged() not being called to the docs for refreshData() back to SC 11.1p. It should be picked up by the next nightly builds.

        Comment


          #5
          Hello, while trying to find a way to add a record count for a grid, based on a single method to implement/observe (without the need to worry about other side effects which might change the record count), I'm trying this:

          Code:
          isc.ListGrid.create({
              ID: "grid",
              width:500, height:300, alternateRecordStyles:true,
              dataSource: supplyItem,
              fields:[
                  {name:"SKU"},
                  {name:"itemName"},
                  {name:"description"},
                  {name:"category"}
              ],
          
              autoFetchData: true,
              showFilterEditor: true,
              filterOnKeypress: true,
              fetchDelay: 500,
              showFilterEditor:true,
              showGridSummary:true,
              getGridSummaryFunction: function(field){
                  var data = grid.data;
                  var lengthIsKnown = (isc.isA.ResultSet(data) && data.lengthIsKnown()) || true;
                  if (lengthIsKnown && field.name === 'category') {
                      foo.setContents(grid.data.getLength());
                  }
              }
          })
          
          grid.addChild(isc.Label.create({ID:"foo", height:30, width:1, border:"1px solid red", snapTo:"BR"}));
          Is it reliable this technique based on getGridSummaryFunction ?
          Will it always be called when the length is known?
          Will it be called for all changes that could alter the record count?

          The only other technique I could think of is using summaryRowDataSource, but it seems a waste as a query for counting the records is already been executed.

          Comment


            #6
            This may work today, but we don't document the timing of when we call that method, so it would not be something you could rely upon in the future.

            Comment

            Working...
            X