Announcement

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

    Issue with applying a previously saved viewState after adding new fields to a grid

    Hi there,

    We are seeing an issue with 8.2 and 8.1 that didn't exist for us previously when we were using 6.5.1.

    We have a list of view states for a grid that are persisted in our database. Some of these view states were saved a long time ago and do not include some fields that were recently added to the grid. Meanwhile, some of the view states were created recently after these fields were added.

    If we apply a new view state that displays one of these new fields and then apply the older view state that doesn't include the new fields at all, the new fields are showing up as visible when the old view state is applied.

    Previously, I believe the showIf logic for the new fields was evaluated to determine if the field should be displayed when applying the old view state. Now, with 8.1 and 8.2, it looks like the showIf logic for these new fields is not evaluated and, if the field was showing prior to applying this old view state, it continues to show.

    This is causing an error where fields are being displayed in a view that shouldn't be displayed. Trying to update every old view state in our database to include a reference to these new fields is not a practical solution for us since we add new fields often.

    So, is it possible to change this behavior to evaluate the showIf logic for the new fields in this case? Or, do you have any other suggested workaround?

    #2
    Just to restate the problem: you are applying viewState which has no settings for some of the fields, so you would normally expect them to appear. However, you've added showIf logic to these fields which should make them not appear. And the problem you're having, is that your showIf logic is not being run for these fields when you call setViewState()?

    Comment


      #3
      Sorry, I know that was a lot of info. But, your summary is not quite right.

      1. Apply a viewState which does have settings for the new fields and the new fields are visible in this viewState.

      2. Switch to an older viewState which does not have settings for the new fields.

      3. The new fields continue to be displayed in the older viewState.

      This didn't happen in previous versions of SmartClient like 6.5.1. If the viewState had no settings for a field, I believe that the showIf logic was evaluated for the fields in 6.5.1. And, the showIf logic is "return false;" for these fields so the desired effect is that they would be hidden.

      Does that make sense?

      Comment


        #4
        Still not quite getting it. Let's go with a concrete example:
        - open the example in the feature explorer at isomorphic/system/reference/SmartClient_Explorer.html#offlinePrefs
        - drag reorder some columns and hit "Persist State"
        - now modify the code as follows:
        Code:
        var ds = isc.DataSource.get("countryDS");
        
        isc.VLayout.create({
            ID:"layout",
            width:500, height:250,
            members: [
                isc.HLayout.create({
                    ID:"buttonLayout",
                    width:"*", height:30,
                    membersMargin: 10,
                    members: [
                        isc.IButton.create({
                            ID: "formulaButton",
                            autoFit: true,
                            title: "Show Formula Builder",
                            click: "countryList.addFormulaField();"
                        }),
                        isc.IButton.create({
                            ID: "stateButton",
                            autoFit: true,
                            title: "Persist State",
                            click: function () {
                                var state = countryList.getViewState();
                                isc.Offline.put("exampleState", state)
                            }
                        })
                    ]
                })
            ]
        });
        
        layout.addMember(isc.ListGrid.create({
            ID: "countryList",
            width:"100%", height:"*",
            alternateRecordStyles:true, cellHeight:22,
            dataSource: ds,
            autoFetchData: true,
            canAddFormulaFields: true,
            canAddSummaryFields: true,
            fields:[
        {name:"foo", showIf:function () {return false;}},
                {name:"countryCode", title:"Flag", width:50, type:"image", imageURLPrefix:"flags/16/", 
                    imageURLSuffix:".png"
                },
                {name:"countryName", title:"Country"},
                {name:"capital", title:"Capital"},
                {name:"population", title:"Population", formatCellValue:"isc.Format.toUSString(value)"},
                {name:"area", title:"Area (km²)", formatCellValue:"isc.Format.toUSString(value)"},
                {name:"gdp", formatCellValue:"isc.Format.toUSString(value)"}
            ]
        }));
        
        isc.Button.create({
            title:"Reset State",
            left:300,
            click : function () {
               var savedState = isc.Offline.get("exampleState");
               if (savedState) {
                    countryList.setViewState(savedState);
               }
            }
        });
        The changes we've made here are
        - added a new field ("foo") with showIf set to a function that returns false
        - put the logic to reset view state into a button click handler so it doesn't run as soon as the page is loaded.

        If you hit "Try It" and click the button to reset the view state, the new "foo" field remains hidden.

        Clearly we're not following exactly what you mean where you describe having a new field with the "showIf" logic set to "return false;" and seeing it show up - can you tweak this example and give us steps to demonstrate what you are seeing / describe how it fails to match what you expect?

        Thanks

        Comment


          #5
          Hi, you were very close to recreating it. The only part you weren't doing is manually using the column select menu to select and display foo prior to clicking "Reset State"

          If you do that and then click "Reset State", then foo is still displaying and it shouldn't. It isn't part of that view state and the default behavior is for that field to be hidden so it should be hidden when "Reset State" is clicked.

          I know we've discussed this with you guys before and this is not a common use case for view states. But, we have a drop-down of view states where the user can have multiple view states to choose from. And, we shouldn't see new fields showing up in existing view states like this. Hopefully it make sense now?

          Comment


            #6
            Yes this is clear.
            It is indeed a tricky area- you've overlaying recorded viewstates for a subset of the total fields in the grid essentially - it's somewhat ambiguous how additional fields should behave - you could make a case for any of
            1) be left alone entirely
            2) being completely hidden
            3) be reset to whatever viewstate they had when the app was loaded, or when the fields were applied to the grid.

            In your usage it sounds like case 3 is the expected behavior and we agree that this is a reasonable way to handle this so we'll make this change.
            It'll take a couple of days for us to get this in - ETA probably middle of next week.
            We'll update the thread and let you know.

            Comment


              #7
              Right, case 3 works for us. Thanks for working on it.

              Comment


                #8
                This should show up in the next nightly build (Feb 8 or greater).
                Please let us know if you don't see it or if it introduces anything unexpected in your usage(s)
                Thanks
                Isomorphic Software

                Comment


                  #9
                  Hi, I've tried your fix. And, I can confirm it does fix the example we constructed. Unfortunately, it doesn't really solve our underlying problem. Sorry, I assumed the fix for the example we constructed would resolve our issue but apparently I was wrong. So, I've altered the example to illustrate our problem even more precisely.


                  -Follow the same steps as before but use this code below

                  - After making foo visible, click the new "Persist State 2" button to save the view state with foo visible

                  -Click "Reset View 2" to apply the view state you just saved

                  -Click "Reset View" to apply the original view state that did not include Foo

                  -Foo is still visible


                  Code:
                  var ds = isc.DataSource.get("countryDS");
                  
                  isc.VLayout.create({
                      ID:"layout",
                      width:500, height:250,
                      members: [
                          isc.HLayout.create({
                              ID:"buttonLayout",
                              width:"*", height:30,
                              membersMargin: 10,
                              members: [
                                  isc.IButton.create({
                                      ID: "formulaButton",
                                      autoFit: true,
                                      title: "Show Formula Builder",
                                      click: "countryList.addFormulaField();"
                                  }),
                                  isc.IButton.create({
                                      ID: "stateButton",
                                      autoFit: true,
                                      title: "Persist State",
                                      click: function () {
                                          var state = countryList.getViewState();
                                          isc.Offline.put("exampleState", state)
                                      }
                                  }),
                                  isc.IButton.create({
                                      ID: "stateButton2",
                                      autoFit: true,
                                      title: "Persist State 2",
                                      click: function () {
                                          var state = countryList.getViewState();
                                          isc.Offline.put("exampleState2", state)
                                      }
                                  })
                              ]
                          })
                      ]
                  });
                  
                  layout.addMember(isc.ListGrid.create({
                      ID: "countryList",
                      width:"100%", height:"*",
                      alternateRecordStyles:true, cellHeight:22,
                      dataSource: ds,
                      autoFetchData: true,
                      canAddFormulaFields: true,
                      canAddSummaryFields: true,
                      fields:[
                  {name:"foo", showIf:function () {return false;}},
                          {name:"countryCode", title:"Flag", width:50, type:"image", imageURLPrefix:"flags/16/", 
                              imageURLSuffix:".png"
                          },
                          {name:"countryName", title:"Country"},
                          {name:"capital", title:"Capital"},
                          {name:"population", title:"Population", formatCellValue:"isc.Format.toUSString(value)"},
                          {name:"area", title:"Area (km²)", formatCellValue:"isc.Format.toUSString(value)"},
                          {name:"gdp", formatCellValue:"isc.Format.toUSString(value)"}
                      ]
                  }));
                  
                  isc.Button.create({
                      title:"Reset State",
                      left:300,
                      click : function () {
                         var savedState = isc.Offline.get("exampleState");
                         if (savedState) {
                              countryList.setViewState(savedState);
                         }
                      }
                  });
                  
                  isc.Button.create({
                      title:"Reset State 2",
                      left:420,
                      click : function () {
                         var savedState = isc.Offline.get("exampleState2");
                         if (savedState) {
                              countryList.setViewState(savedState);
                         }
                      }
                  });

                  Comment


                    #10
                    Just a quick update to let you know we see this behavior (and understand it's cause). We should get this fixed early next week for you.

                    Comment


                      #11
                      We've made a change that should address this. Please try the next nightly build and let us know!

                      Thanks
                      Isomorphic Software

                      Comment


                        #12
                        Thanks, looks good!

                        Comment

                        Working...
                        X