Announcement

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

    Disabling empty data-bound SelectItems

    Hi

    I have a SelectItem in a form which I'd like to disable when there are no values displaying in it.

    The data is loaded up from a datasource and then filtered on the client side (I've overriden getPickListFilterCriteria()) and everything seems to work fine.

    The problem is, I'm having a really difficult time trying to get the number of options that are currently displayed when filtered - Smart GWT just doesn't seem to have that information anywhere.

    Things I have tried so far:

    - filterClientPickListData() - this seems to return null for data bound pick lists
    - add a DataArrivedHandler and extract the ResultSet directly. However each method I seemed to call on the ResultSet that was a subclass of RecordList seemed to be broken, i.e. it came up with "self.getLength is not a function".

    I can't believe that something which is seemingly so simple is so complicated to achieve. If anyone has any ideas I'd be very grateful.

    Smart GWT version: 2.2
    Browser: Firefox 3.6.6

    Thanks,
    Phill

    #2
    Have you already tried DataArrivedEvent.getEndRow() or are you saying that's not working?

    Can you show a test case for this situation where you are seeing a problem with the ResultSet object?

    Comment


      #3
      Originally posted by Isomorphic
      Have you already tried DataArrivedEvent.getEndRow() or are you saying that's not working?
      getEndRow does work, but the data is only loaded once - it's filtered on the client side. This is the issue you see, I need to get the number of options being displayed once the data has been filtered.

      Originally posted by Isomorphic
      Can you show a test case for this situation where you are seeing a problem with the ResultSet object?
      I don't have time to set up a green fields app, however if I add the following code into my form:

      Code:
      new SelectItem()
      {
          private ResultSet _resultSet;
      
          {
              setName( "Test" );
              setTitle( "Testing" );
              setOptionDataSource( new ApplicabilityDataSource( 2 ) );
      
              addDataArrivedHandler( new DataArrivedHandler()
              {
                  @Override
                  public void onDataArrived( DataArrivedEvent event )
                  {
                      _resultSet = event.getData();
                  }
              } );
          }
      
      
          @Override
          public void clearValue()
          {
              if (null != _resultSet)
              {
                  _resultSet.setCriteria( getPickListFilterCriteria() );
                  int length = _resultSet.getLength();
              }
          }
      
          @Override
          protected Criteria getPickListFilterCriteria()
          {
              Integer model = (Integer) CatalogueFilterForm.this.getValue( MODEL );
      
              if (null != model)
              {
                  Criteria criteria = new Criteria( "hierId", model.toString() );
      
                  return criteria;
              }
      
              return null;
          }
      }
      I get an error on the line _resultSet.getLength().

      Code:
      Uncaught exception escaped : com.google.gwt.core.client.JavaScriptException
      (TypeError): self.getLength is not a function
       fileName: http://localhost:8000
       lineNumber: 190
       stack: ()@http://localhost:8000:190
      @:0
      ([object GWTJavaObject],131108,[object GWTJavaObject])@http://localhost:8000/epc/hosted.html?epc:56
      ([object Object],[object Object],766134)@http://localhost:8000:456
      ((function () {var param = {form: arguments[0], item: arguments[1], value: arguments[2]};var event = __gwt_makeJavaInvoke(1)(null, 11665437, param);__gwt_makeJavaInvoke(1)(selfJ, 131108, event);}),[object Object],[object Object])@http://localhost:8000:6
      @:0
      (null,65560,(function () {var param = {form: arguments[0], item: arguments[1], value: arguments[2]};var event = __gwt_makeJavaInvoke(1)(null, 11665437, param);__gwt_makeJavaInvoke(1)(selfJ, 131108, event);}),[object Object],[object Object])@http://localhost:8000/epc/hosted.html?epc:56
      [...]

      Comment


        #4
        Confirmed the issue. This will be fixed shortly.

        Sanjiv

        Comment


          #5
          This has been fixed. Please pick up the latest nightly build.

          Sanjiv

          Comment

          Working...
          X