Announcement

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

    #16
    You are most likely returning "false" as a String rather than a true Boolean false value.

    Comment


      #17
      Hi Isomorphic, thank you.

      Yes, I was passing "false" or "true" as String rather than a real boolean value. Is there any way to reload dynamic ds and the related data just after removing a record? I am setting canRemoveRecord to true. So perhaps will be necessary to refresh the grid in order to remove a column just after its related data does not exists anymore. Should be something like an afterRemove event or something like this.

      Comment


        #18
        If your server responds correctly to the remove operation, update of the grid's dataset is automatic. Read about automatic cache synchronization in the QuickStart Guide and in the ResultSet class javadoc.

        Comment


          #19
          Originally posted by Isomorphic View Post
          If your server responds correctly to the remove operation, update of the grid's dataset is automatic. Read about automatic cache synchronization in the QuickStart Guide and in the ResultSet class javadoc.

          Yes, when I delete a record, a line from de grid desapear and the related DMI ds method is being invoked, but remember that my ds columns were dynamic generated base on the data, when I delete a record it is possible that some column should not appear anymore (look at for the first doubt posted). If I reload my dynamic ds, this column is not present. However, the grid do not reflect this change. I tried to invoke, .clear(), I tried to .redraw() the grid and nothing happens.

          Comment


            #20
            Hi vitor,

            please see the note in my post #4
            Code:
            Make sure to have a different Datasource-ID for every different columnList (or always a different Datasource-ID).
            and also this comment by Isomorphic in another thread.

            If your column list changes (and you want the ListGrid to change as well) you should re-get the .ds.xml definition via DataSource.load(yourDSName). It has a "force" parameter.
            You'll most likely have to destroy and recreate the whole ListGrid then.
            Note that this only affects the client - the server might show errors if the returned XML is not constant for an DataSource-ID (see above).

            Best regards
            Blama

            Comment


              #21
              Originally posted by Blama View Post
              You'll most likely have to destroy and recreate the whole ListGrid then.
              Hi Blama, I must thak you so much for the help, and Isomorphic as well.

              I was calling .clear() from the ListGrid, thinking that would resolve. As a matter of fact, did not take any effect. So I did a test right now, following your suggestion above, and the grid disappeared, Below is possible to see how I am instantiating the grid, even I calling this method soon after .destroy() the grid, cannot create it again.

              Code:
              public ListGrid getGrid() {
                      
                      if (grid == null) {
                          
                          grid = new ListGrid();
                          grid.setTitle(scatext.screen_lunummernkreis_grid());
                          grid.setWidth100();
                          grid.setAutoFetchData(false);
                      //    grid.setAutoFitFieldWidths(true);
                      //    grid.setAutoFitWidthApproach(AutoFitWidthApproach.BOTH);
                          grid.setAlternateRecordStyles(true);
                          grid.setCanGroupBy(false);
                          grid.setSelectionType(SelectionStyle.SINGLE);
                          grid.setDataFetchMode(FetchMode.BASIC);
                          grid.setShowAllColumns(true);
                          grid.setShowAllRecords(true);
                          grid.setCanRemoveRecords(true);
                          grid.setWarnOnRemoval(true);
                          grid.setWarnOnRemovalMessage(scatext.prompt_grid_onremoval());
                          grid.setSelectOnEdit(true);
                          grid.setVirtualScrolling(true);
                          
                          this.addMember(grid, 0);
                          
                      }
                      
                      return grid;
                  }
              Last edited by vitor.eduardods; 16 Sep 2016, 05:56.

              Comment


                #22
                Hi,

                grid.destroy() does not destroy the java object, so your if will only run once.
                Do a grid = null; after your grid.destroy() and before calling getGrid() again.

                Best regards
                Blama

                Comment


                  #23
                  I am overrinding remove from grid by setting setCanRemoveRecords to true and adding a handler for addRemoveRecordClickHandler. This is the code for that:

                  Code:
                      /**
                       * @return the gridRemoveRecordClickHandler
                       */
                      public RemoveRecordClickHandler getGridRemoveRecordClickHandler() {
                          
                          if (gridRemoveRecordClickHandler == null) {
                              
                              gridRemoveRecordClickHandler = new RemoveRecordClickHandler() {
                                  
                                  @Override
                                  public void onRemoveRecordClick(RemoveRecordClickEvent event) {
                                      
                                      final ListGridRecord record = display.getLayout().getGrid().getSelectedRecord();
                                      
                                      display.getLayout().getGrid().removeData(record, new DSCallback() {
                                          
                                          @Override
                                          public void execute(DSResponse dsResponse, Object data, DSRequest dsRequest) {
                                              
                                              generateNumberRangesDataSourceDynamycally();
                                              
                                          }
                                          
                                      });
                                      
                                  }
                                  
                              };        
                              
                          }
                          
                          return gridRemoveRecordClickHandler;
                      }
                  The method
                  Code:
                  generateNumberRangesDataSourceDynamycally()
                  is where the magic occurs i.e., where is the logic for reload the dynamic ds and recreate the grid. By follow your instructions when I insert a new row, that will need a new column in the grid, works fine, the grid is recreated with the new column. But, when a line is deleted and the code above should be executed nothing happens. Iteresting realize that the removed line disappear before I can confirm that the line should be removed (
                  Code:
                  grid.setWarnOnRemoval(true); grid.setWarnOnRemovalMessage(scatext.prompt_grid_onremoval());
                  )

                  What could be the problem?

                  Comment


                    #24
                    Do you see 2 requests for 1 click in the Developer Console's RPC Tab?
                    If so, add event.cancel() to the top of onRemoveRecordClick() (see the docs for addRemoveRecordClickHandler()).

                    Best regards
                    Blama

                    Comment


                      #25
                      Thank you Blama about your suggestion regarding
                      Code:
                      add [I]event.cancel()[/I]
                      However, my grid still not refresh after deleting a row, or inserting a new. See my entire code below for this feature:
                      • DMI call for generate the dynamic ds:
                      Code:
                         
                      private void generateNumberRangesDataSourceDynamycally() {
                              
                              String appID = AppServiceConstants.APP_ID;
                              String className = AppServiceConstants.SCAFACADE_SERVICE_NAME;
                              String methodName = AppServiceConstants.METHOD_GETNUMBERRANGES;
                              
                              DMI.call(appID, className, methodName, new PAIRPCCallback() {
                                  
                                  @Override
                                  public void executeRPCCall(RPCResponse response, Object rawData, RPCRequest request) {
                                      
                                      if (response.getStatus() == RPCResponse.STATUS_FAILURE) {
                                          
                                          SC.warn( scatext.error_numberrange_datasource_generation() );
                                          
                                      }
                                      
                                  }
                                  
                              }, loadNumberRangesDataSource());
                              
                          }
                      • Method for load dynamic ds:
                      Code:
                          private Object[] loadNumberRangesDataSource() {
                              
                              DataSource.load(LUNummernkreiseContent.DYNAMICDS_ID, dataSourceCallbackFunction(), true);
                              
                              return new Object[] { AppController.getRequestToken() };
                              
                          }
                      • Function callback for ds loading
                      Code:
                          private Function dataSourceCallbackFunction() {
                              
                              final Function function = new Function() {
                                  
                                  @Override
                                  public void execute() {
                                      
                                      dsDynamic = DataSource.get( LUNummernkreiseContent.DYNAMICDS_ID );
                                      
                                      if (dsDynamic != null) {
                                          
                                          setupGrid();
                                          refreshGrid();
                                          
                                          
                                      }
                                  }
                                  
                              };
                              
                              return function;
                          }
                      • Methods for setting up the grid and refresinh after dynamic ds has been loaded:
                      Code:
                          protected void setupGrid() {
                              
                              display.getLayout().getGrid().destroy(); // destroying the HTML reference for the component;
                              display.getLayout().setGrid( null ); // nullifying the java object
                              display.getLayout().getGrid().setDataSource( dsDynamic );
                      
                              final HeaderSpan headerSpan = new HeaderSpan(scatext.screen_lunummernkreis_grid_luHeaderSpan(),
                                      new String[] {LUNummernkreiseContent.START_FIELD, LUNummernkreiseContent.END_FIELD});
                      
                              display.getLayout().getGrid().setHeaderSpans( headerSpan );
                              display.getLayout().getGrid().getField( LUNummernkreiseContent.START_FIELD ).setTitle( scatext.screen_lunummernkreis_window_spinnerFrom() );
                              display.getLayout().getGrid().getField( LUNummernkreiseContent.END_FIELD ).setTitle( scatext.screen_lunummernkreis_window_spinnerTo() );
                              display.getLayout().getGrid().getField( LUNummernkreiseContent.DELIVERYTYPE_FIELD ).setTitle( scatext.screen_lunummernkreis_window_comboType() );
                              display.getLayout().getGrid().getField( LUNummernkreiseContent.COUNTRYNAME_FIELD ).setTitle( scatext.screen_lunummernkreis_window_comboCountry() );
                              display.getLayout().getGrid().getField( LUNummernkreiseContent.COUNTRYCODE_FIELD ).setTitle( scatext.screen_lunummernkreis_grid_columnCountryCode() );
                              
                          }
                      
                          protected void refreshGrid() {
                              
                              display.getLayout().getGrid().fetchData( criteria );
                              
                          }
                      After save a new record in a modal I am invoking the first method generateNumberRangesDataSourceDynamycally(). I implemented the handler for deleting a grid line in order to invoke the same method in delete callback, but without success.

                      Any idea?

                      Comment


                        #26
                        Blama, since we have to restart the server in order to have a new descriptor for the same DataSource-ID, my question is: If I implement an DataSource-ID generator toward use a different ID for each server request, what should be the chance that I have performance problems in the future regarding so many unuseful DataSources loaded?

                        Comment


                          #27
                          That's one for Isomorphic to answer, but:
                          • The system is implemented this way (prefix, regex) for this very reason, so I suppose it will work
                          • I'm pretty sure I read somewhere that the actual XML file is cached, so the overhead is only XML processing, no file system IO.
                          • There is a DataSource pool and you can decide if your dynamic DS are allowed to be in the pool, which might be a bad idea if you have one-time DS in a high frequency, but I don't know that. But this is also doc'd somewhere.
                          Best regards
                          Blama

                          Comment

                          Working...
                          X