Announcement

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

    ListGrid::removeRecordClick(int row) is not called when remove icon is clicked

    Hello,

    currently I evaluating the smartgwt enterprise edition (3.1d) and got the problem, that the method ListGrid::removeRecordClick(int row) is not called when the remove icon is clicked.

    According to the Javadoc and the doc of the ListGrid.js this should be an overwrite point:

    May be overridden to perform custom logic on remove click.

    #2
    Sorry for the confusion on this.
    We've now added an explicit event to make modifying remove record click behavior straightforward.
    As of the next nightly build - dated September 20 or greater - this should show up (look for 'addRemoveRecordClickHandler(...)')

    Regards
    Isomorphic Software

    Comment


      #3
      Thank you for the fast fix. I testet it today with the nightly build (3.1d/EnterpriseEval/2012-09-20). Now I got the problem, that this event is triggered before the changes are reflected by the method ListGrid:hasChanges().
      It's my aim to show a button as soon as changes have been made on the ListGrid.

      Comment


        #4
        I have a similar problem. I'm trying to enable a button after a remove click occurs but only when the total rows in the ListGrid are > 0 and there are no errors.

        I tried adding a RemoveRecordClickHandler, but the ListGrid are properties are not yet updated in the handler (e.g., ListGrid.getTotalRows() and hasErrors() return values from before the remove button is clicked). Any help is appreciated. Thanks!

        FF26. SmartGWT 4.1p-2014-09-10. GWT 2.5.1

        Comment


          #5
          By the way, I tried overriding removeRecordClick and it was never called in the debugger.

          Comment


            #6
            You should just enable or disable your button every time DataChanged fires. There's no reason to try to hook removeRecordClick specifically.

            Comment


              #7
              I don't see a addDataChangedHandler() in ListGrid.

              Comment


                #8
                The event fires on the data object (ResultSet).

                Comment


                  #9
                  It's on ListGrid.getResultSet().

                  Comment


                    #10
                    Thanks for the replies.

                    I'm trying to set the handler on initialization of the ListGrid. The call to ListGrid.getResultSet() returns null. Any pointers?

                    By the way, the ListGrid does not make any fetches nor does it have a data source.

                    I tried ListGrid.setData() with a new ResultSet I created but I get a create()[]: _1 is null exception.

                    Comment


                      #11
                      See ListGrid.fetchData() - calling this is what automatically creates a ResultSet.

                      You didn't specify how you are setting data for the grid, but the same DataChanged API also exists on RecordList.

                      As far as having setData() not work with ResultSet - this is probably some basic problem like not providing a DataSource to the ResultSet at all (invalid, obviously), but we can only help if we have all the usual details about the error (stack trace, surrounding logs etc).

                      Comment


                        #12
                        Thanks for the RecordList suggestion. However, the code is not going into the DataChangedHandler I added to the RecordList.

                        Code:
                        ListGrid grid = new ListGrid();
                        grid.setCanRemoveRecords(true);
                        
                        RecordList list = new RecordList();
                        list.addDataChangedHandler(new DataChangedHandler() {
                          // enable search button when grid.getTotalRows > 0 && !grid.hasErrors
                        ); 
                        grid.setData(list);
                        The ListGrid is populated by an add button that calls ListGrid.startEditingNew().

                        Comment


                          #13
                          This:

                          The ListGrid is populated by an add button that calls ListGrid.startEditingNew().
                          .. was an extremely important detail to share - it means that you are removing unsaved user input, and never changing the data model as such at all. So DataChanged will not fire.

                          This also means there's no asynchronous action to save changes. The user input is discarded immediately after the RemoveRecordClick handler fires, and your handler code has exited (meaning you have declined to cancel() the event).

                          The simplest way to execute something at this time is just to use the core GWT Scheduler API to schedule an action when RemoveRecordClick. It doesn't matter how long the delay is, it can be minimal - there's no race condition possibly because, as explained above, the edits are discarded immediately.

                          Comment

                          Working...
                          X