Announcement

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

    ListGrid.cancelEditing does not work as expected

    GWT v2.5
    SmartGWT 3.1d EE, (v8.3p_2012-12-28Enterprise Isomorphic-SmartClient-Package-Date: 2012-12-28)
    Browser: IE8
    Environment: Eclipse Indigo
    Java 1.6

    I have a refresh button for a listgrid. If changes are detected I prompt to save changes. If no is the response I call cancelediting, invalidatecache, and fetch. But when the results return, the edits are still shown in the grid.

    Please advise.

    #2
    cancelEditing() just stops editing. You want discardAllEdits(), and you do not need the subsequent calls to invalidateCache or fetch.

    Comment


      #3
      That is still not working.

      /**
      * The basic function is to refresh on command. We first ask the
      * grid if there have been any edits and if so we give the user a chance to save them.
      * doRefresh() has to be called in an if else so that the sequence of prompting a save
      * and the refresh is synchronous, otherwise it refreshes before the user can respond
      * to the prompt
      *
      */
      private void refreshGrid()
      {
      if (quickQuoteGrid.hasChanges())
      {
      SC.ask("Refreshing...you have unsaved changes. Save now?", new BooleanCallback()
      {
      public void execute(Boolean value)
      {
      if (value != null && value)
      {
      quickQuoteGrid.saveAllEdits();
      showStatus("changes saved successfully");
      doRefresh();
      }
      }
      });
      }
      else
      {
      quickQuoteGrid.discardAllEdits();
      doRefresh();
      }

      }

      /**
      * This is a helper method used by refreshGrid(). It should NEVER be called from any other method
      */
      private void doRefresh()
      {
      quickQuoteGrid.invalidateCache();
      showHEFields();
      lastRefresh.setContents(new Date().toString());
      }

      Comment


        #4
        bump
        bump
        bump

        Comment


          #5
          You should call endEditing() or cancelEditing() first before calling discardAllEdits(), otherwise, there is still an editor active which could produce new edit values after the previous set has been discarded.

          Comment


            #6
            Ok, this worked. Also, it didn't help that the cancelling code wasn't being reached. All good now. Thanks!

            Comment

            Working...
            X