Announcement

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

    Record gets removed after updating in ListGrid

    I have this "strange" situation where I want an update of a ListGrid record to return multiple records. A (self-made) filter is active on the grid and its values are returned by an overridden getCriteria() method. When updating the record, it no longer applies to the criteria, but I still want to have it visible (until an explicit refresh of the data is done). I found this property "neverDropUpdatedRows" that I can set on the "dataProperties" property of the grid, but that is no longer defined after the update. I read something in another thread that this dataProperties are only used in fetchData(). I have no clue of how to set in - for example - updateData() or where it gets deleted (if that is the case at all).

    So basically I want to have in-line editing and if one record changes, it returns multiple records because their values are dependent on that other record. This more or less works (I simply return an array of data and the grid nicely updates them all). But if the record edited no longer fits the criteria, it gets dropped. I don't want that. Setting neverDropUpdatedRows on the dataProperties doesn't help.

    #2
    Hi wallytax,

    how about this workaround:
    • A new .ds.xml column: name"updated" type="boolean" customSelectExpression="0" sqlStorageStrategy="singleChar10"
    • In the relatedUpdate you return set the value to "1"
    • Make your criteria OR(updated=true, yourOldCriteria)
    This is only if it is not possible with features the framework already provides.

    Best regards
    Blama

    Comment


      #3
      See docs - dataProperties is used to create the ResultSet that becomes grid.data, and neverDropUpdatedRows is a ResultSet property which applies to all operationTypes.

      It is true that the ResultSet is normally created by a fetchData() call and that you need to set any properties on dataPropertied before making that call.

      Comment


        #4
        I found out the following: the property gets undefined after calls to refreshData(). So in my grid I also use refreshData() and if I do that, the neverDropUpdatedRows gets removed. I guess a new ResultSet is created within that method, so I had to try something else. I now use @invalidateCache() to do what I wanted to achieve with refreshData() because fetchData() didn't do a refetch if none of the criteria changed.

        Comment


          #5
          I've made certain decisions because things weren't working for my application. Somehow I decided to use refreshData() when I want to reload the grid data (for example if a colleague has added a record). Using fetchData() didn't work, using invalidateCache doesn't always apply certain search filters (I've added a custom search form as grid component). I've been going through the source code of SmartClient and after long searching I've found more or less ways to get what I want, but it wasn't easy at all. For me - even after more than 3 years of usage - a lot of things seem to be redundant or not 100% clear. To reload my grid data, I more or less can do these things:
          • filterData() - haven't really looked into that
          • fetchData() - wasn't reloading if the criteria hadn't change
          • invalidateCache() - was using the initial criteria that were used on auto fetch
          • refreshData() - dropped the dataProperties subproperty neverDropUpdatedRows
          Any advice on that?

          Comment


            #6
            This isn't really a mysterious area.

            fetchData() and filterData() clearly document that they don't initiate a new fetch if criteria are unchanged, and the docs go on to tell you about invalidateCache() for forcing a reload (and the doc even links to refreshData() too).

            invalidateCache() uses the current sort and filter applied to the grid, as it is doc'd to do. If you're not seeing this, it may be a usage issue or a bug, and you should look into it.

            refreshData() does indeed drop the neverDropUpdatedRows setting, but it doesn't seem that these two APIs make sense together. If you are trying to retain updated rows that no longer match criteria, but then you use refreshData(), obviously those rows will disappear. So what were you hoping for here?

            Comment

            Working...
            X