Announcement

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

    Regression - grouping mode is undefined when first selecting from context menu

    SmartClient_v101p_2016-02-18_PowerEdition

    We have a field that has two custom grouping modes. For brevity purposes I have omitted the details of the grouping handler. When you select a grouping mode from the context menu, the mode is null. However, if you select it again, it has the correct value. This causes issues obviously as our grid is not grouped correctly the first time.

    THis worked in our previous SC release, SmartClient_v91p_2014-04-10_PowerEdition

    REPRO steps:
    ===========
    1. Load test case
    2. Right click Path column, Group By "Full"
    3. Observe in console that the group mode is undefined
    4. Repeat step 2
    5. Observe in console that the group mode is noe Full


    Code:
    <!DOCTYPE html>
    
    <html>
    <head>
        <title ></title>
        
        <style>
                .diagInfo {
                    font-size: 14px;
                    font-weight: bold;
                    padding: 5px;
                }
            </style>
            
           <script type="text/javascript" >
            var isomorphicDir="http://localhost:8080/isomorphic/";
    
            
                
    </script>
        
     <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/modules/ISC_Core.js"></script>
     <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/modules/ISC_Foundation.js"></script>
     <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/modules/ISC_Containers.js"></script>
      <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/modules/ISC_Grids.js"></script>
     <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/modules/ISC_Forms.js"></script>
     <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/modules/ISC_DataBinding.js"></script>
     <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/modules/ISC_Drawing.js"></script>
     <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/modules/ISC_PluginBridges.js"></script> 
     <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/modules/ISC_Charts.js"></script>
     <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/modules/ISC_Tools.js"></script>
     <script type="text/javascript" SRC="http://localhost:8080/isomorphic/skins/EnterpriseBlue/load_skin.js"></script>
    
    </head>
    <body>
    
     <script type="text/javascript">
    
        var data = [
                { project: "123 Avenue", path:"East->GA->Atlanta->Engineering", redflag: "", owner: "University of MD", ins: 33, obs: 231, unsafe: 9, safe: 222, insDate: "10/12/2011", score:"<img src='star-4.png'/>55%", score:"<img src='star-4.png'/>55%", link:"<a href=''>View Analysis</a>" },
                { project: "Long Project Name", path:"East->PA->Pittsburgh->Engineering",redflag: "", owner: "University of MD", ins: 33, obs: 231, unsafe: 9, safe: 222, insDate: "10/12/2011", score:"<img src='star-4.png'/>55%", link:"<a href=''>View Analysis</a>" },
                { project: "6789 Avenue B", path:"East->PA->Pittsburgh->Finance",redflag: "", owner: "University of MD", ins: 33, obs: 23, unsafe: 9, safe: 222, insDate: "10/12/2011", score:"<img src='star-4.png'/>55%", link:"<a href=''>View Analysis</a>" },
                { project: "123 Avenue", path:"East->PA->Pittsburgh->Maintenance",redflag: "", owner: "University of MD", ins: 33, obs: 231, unsafe: 9, safe: 222, insDate: "10/12/2011", score:"<img src='star-4.png'/>55%", link:"<a href=''>View Analysis</a>" }
            ];
    
            // ===== DO NOT REMOVE =====
                var diagLabel = isc.Label.create({
                            ID: "diagInfo",
                            width: "100%",
                            styleName: "diagInfo",
                            autoFit: true
                        });
                // ===== DO NOT REMOVE =====
                
    </script>
    
    </head>
    
    <body>
    
        <script type="text/javascript">
    
        // set this to the correct JIRA ticket
                var JIRA_TICKET = "group_regression";
                
        // once page loads set some diagnostic information, DO NOT CHANGE
                isc.Page.setEvent("load", function() {
                    document.title = JIRA_TICKET + "   (SmartClient version " + isc.versionNumber + ")";
                    var html = [];
                    html.push("Jira: " + JIRA_TICKET);
                    html.push("SmartClient: " + isc.versionNumber);
                    html.push("Browser: " + navigator.appCodeName + " " + navigator.appName + " " + navigator.appVersion);
                    diagLabel.setContents( html.join("<br>"));
                });
                
        isc.DataSource.create({
                ID: "ds",
                cacheData:data,
                clientOnly: true
            });
    
            
            
            var grid = isc.ListGrid.create({
                dataSource : ds,
                fields: [
                {name:"path", title:"Path", type:"text", groupingModes:["Normal", "Full"]},
                {name:"project", title:"Project", type:"text" }
                    
                ],
                dataFetchMode : "local",
                autoFetchData: true,
                width : 1200,
                align : "center",
                autoDraw: false,
                autoFitData : "vertical",
                autoFitMaxHeight : 600,
                alternateRecordStyles : true,
                canGroupBy : true,
                showGroupSummary : true,
                canMultiGroup : true,
                useAdvancedFieldPicker : true,
                advancedFieldPickerThreshold : 3
    
            });
                
            var layout = isc.VLayout.create({
                    width:"100%",
                    membersMargin: 20,
                    members: [
                        // ===== DO NOT REMOVE diagLabel
                        diagLabel,
                        // ===== place anty components here
                        grid
                    ]
                });
    
            // =============== hierarchy grouping functionality ===============
        
            grid.handleGroupBy = function(fields) {
                    
                    for (var i = 0; i < fields.length; i++) {
                        var f = grid.getField(fields[i]);
                        console.log(f.name + " grouping mode=" + f.groupingMode);
                    }
                                    
                    // this method fires when the grid is grouped. Since we are modifying
                    return true;
                }
    
                </script>
                
                
    </body>
    
    </html>

    #2
    In fact, what you're seeing here is not that your code works the second time, but rather that you happened to pick the same groupingMode twice - a call to getGroupingMode() from the groupBy handler returns the value of field.groupingMode as it stands *before* this grouping request, because the groupBy handler can cancel the grouping operation. In 9.1, we set the requested groupingMode on the field before requesting the group operation, because the handler has no other way to access to the new groupingMode - but it was never reverted if the group operation was cancelled, so the mechanism was broken anyway.

    We've re-instated (and fixed) this legacy behavior, of setting the groupingMode on the field before the groupBy handler fires - so your old code will work again now.

    However - note that, since your old versoin, we've added support for GroupSpecifiers, which detail various data about a group-field, rather than just it's name - including groupingMode.

    As of tomorrow's builds, we've tweaked handleGroupBy(), adding a second parameter - specifiers - this is an array of the GroupSpecifiers associated with the *requested* (new) group-fields, including the groupingMode - you should check these instead of doing getField(passedFieldName).

    Comment


      #3
      Good to know, as my code looked like this to handle both cases in 9.1. I had to handle both cases in order for grouping to work properly, so hopefully this is simplier in 10.1.
      Code:
      _gridObject.handleGroupBy = function(fields) {
      
                    ...
                      for (var i = 0; i < fields.length; i++) {
                          // get the field to be grouped and the mode so we can check
                          if (typeof (fields[i]) == "string") {
                              fieldName = fields[i];
                              var f = _gridObject.getField(fields[i]);
                              if (f != null)
                                  groupingType = f.groupingMode;
                          } else {
                              fieldName = fields[i].property;
                              groupingType = fields[i].grouping;
                          }

      Comment


        #4
        Thanks...verified in my dev environment.

        Comment


          #5
          SmartClient_v101p_2016-03-07_PowerEdition

          This was fixed for the above test case, however there is still an issue with the test case below (using the group by dialog). Furthermore, I cannot get specifiers to come back into the handleGroupBy() method of ListGrid:

          REPRO Steps:
          ==============
          1. Load test case
          2. Open Configure Grouping dialog
          3. Choose PAth and mode "FULL"
          4. Observe that the console shows undefined for the field's groupingMode and also for specifiers
          5. Repeat steps 2 and 3
          6. Observe that the console shows "FULL" for the field's grouping mode, but still shows undefined for specifiers

          This was fixed per your comments above when using the Group By Path -> Full from the context menu, but not when using the dialog.

          Code:
          <!DOCTYPE html>
          
          <html>
          <head>
              <title ></title>
              
              <style>
                      .diagInfo {
                          font-size: 14px;
                          font-weight: bold;
                          padding: 5px;
                      }
                  </style>
                  
                 <script type="text/javascript" >
                  var isomorphicDir="http://localhost:8080/isomorphic/";
          
                  
                      
          </script>
              
           <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/modules/ISC_Core.js"></script>
           <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/modules/ISC_Foundation.js"></script>
           <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/modules/ISC_Containers.js"></script>
            <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/modules/ISC_Grids.js"></script>
           <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/modules/ISC_Forms.js"></script>
           <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/modules/ISC_DataBinding.js"></script>
           <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/modules/ISC_Drawing.js"></script>
           <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/modules/ISC_PluginBridges.js"></script> 
           <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/modules/ISC_Charts.js"></script>
           <script type="text/javascript" SRC="http://localhost:8080/isomorphic/system/modules/ISC_Tools.js"></script>
           <script type="text/javascript" SRC="http://localhost:8080/isomorphic/skins/EnterpriseBlue/load_skin.js"></script>
          
          </head>
          <body>
          
           <script type="text/javascript">
          
              var data = [
                      { project: "123 Avenue", path:"East->GA->Atlanta->Engineering", redflag: "", owner: "University of MD", ins: 33, obs: 231, unsafe: 9, safe: 222, insDate: "10/12/2011", score:"<img src='star-4.png'/>55%", score:"<img src='star-4.png'/>55%", link:"<a href=''>View Analysis</a>" },
                      { project: "Long Project Name", path:"East->PA->Pittsburgh->Engineering",redflag: "", owner: "University of MD", ins: 33, obs: 231, unsafe: 9, safe: 222, insDate: "10/12/2011", score:"<img src='star-4.png'/>55%", link:"<a href=''>View Analysis</a>" },
                      { project: "6789 Avenue B", path:"East->PA->Pittsburgh->Finance",redflag: "", owner: "University of MD", ins: 33, obs: 23, unsafe: 9, safe: 222, insDate: "10/12/2011", score:"<img src='star-4.png'/>55%", link:"<a href=''>View Analysis</a>" },
                      { project: "123 Avenue", path:"East->PA->Pittsburgh->Maintenance",redflag: "", owner: "University of MD", ins: 33, obs: 231, unsafe: 9, safe: 222, insDate: "10/12/2011", score:"<img src='star-4.png'/>55%", link:"<a href=''>View Analysis</a>" }
                  ];
          
                  // ===== DO NOT REMOVE =====
                      var diagLabel = isc.Label.create({
                                  ID: "diagInfo",
                                  width: "100%",
                                  styleName: "diagInfo",
                                  autoFit: true
                              });
                      // ===== DO NOT REMOVE =====
                      
          </script>
          
          </head>
          
          <body>
          
              <script type="text/javascript">
          
              // set this to the correct JIRA ticket
                      var JIRA_TICKET = "group_regression";
                      
              // once page loads set some diagnostic information, DO NOT CHANGE
                      isc.Page.setEvent("load", function() {
                          document.title = JIRA_TICKET + "   (SmartClient version " + isc.versionNumber + ")";
                          var html = [];
                          html.push("Jira: " + JIRA_TICKET);
                          html.push("SmartClient: " + isc.versionNumber);
                          html.push("Browser: " + navigator.appCodeName + " " + navigator.appName + " " + navigator.appVersion);
                          diagLabel.setContents( html.join("<br>"));
                      });
                      
              isc.DataSource.create({
                      ID: "ds",
                      cacheData:data,
                      clientOnly: true
                  });
          
                  
                  
                  var grid = isc.ListGrid.create({
                      dataSource : ds,
                      fields: [
                      {name:"path", title:"Path", type:"text", groupingModes:["Normal", "Full"]},
                      {name:"project", title:"Project", type:"text" }
                          
                      ],
                      dataFetchMode : "local",
                      autoFetchData: true,
                      width : 1200,
                      align : "center",
                      autoDraw: false,
                      autoFitData : "vertical",
                      autoFitMaxHeight : 600,
                      alternateRecordStyles : true,
                      canGroupBy : true,
                      showGroupSummary : true,
                      canMultiGroup : true,
                      useAdvancedFieldPicker : true,
                      advancedFieldPickerThreshold : 3
          
                  });
                      
                  var layout = isc.VLayout.create({
                          width:"100%",
                          membersMargin: 20,
                          members: [
                              // ===== DO NOT REMOVE diagLabel
                              diagLabel,
                              // ===== place anty components here
                              grid
                          ]
                      });
          
                  // =============== hierarchy grouping functionality ===============
              
                  grid.handleGroupBy = function(fields, specifiers) {
                          
                          for (var i = 0; i < fields.length; i++) {
                              var f = grid.getField(fields[i]);
                              console.log(f.name + " grouping mode=" + f.groupingMode);
                          }
                          
                          console.dir(specifiers);
                                          
                          // this method fires when the grid is grouped. Since we are modifying
                          return true;
                      }
          
                      </script>
                      
                      
          </body>
          
          </html>

          Comment


            #6
            The missing "specifiers" param is fixed for tomorrow's builds. We'll update on the group dialog issue once we've had a chance to look into it.

            Comment


              #7
              As you're aware, handleGroupBy() is a cancellable notification - calling getField() here returns the field object as it is right now, before any changes applied by this latest grouping attempt. So, it was never valid (and never documented) to expect getField().groupingMode to be set to what *will* be it's new groupingMode if the process is not cancelled.

              However, we re-instated that behavior for the groupBy menuItems because it *had* once worked there and, at that time, there was no other way to figure out the new groupingMode.

              The MultiGroupDialog never had this facility, so we don't intend to add it now.

              As of recent builds, the correct way to detect everything about a group spec is to consult the new "specifiers" param which is now correctly passsed to handleGroupBy().

              Comment

              Working...
              X