Announcement

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

    Hint required - automatically filter by first item in FilterEditor's SelectItem

    I have a ListGrid showing a FilterEditor. The first field on the grid, BUSINESS_CODE, has an optionDataSource defined in the ds.xml file so the FilterEditor correctly shows what appears to be a SelectItem containing a blank followed by the 4 business codes in my test database A, B, C and D.

    The question is how do I code so that by default the first business code is selected and the grid is filtered by business code before showing the grid to the user? So with my test data the grid would only display rows with business code A. (The user can then select another business code, or none, if desired).

    I know that setDefaultToFirstOption on a SelectItem will pick the first option but how do I get a reference to the SelectItem in the FiltorEditor?
    I've also thought about setting the grid criteria, but is there a way to use the data that the optionDataSource retrieves, instead of having to issue a DSRequest to retrieve the same information?

    Any hints on how to achieve this will be appreciated. Thanks.

    SmartClient Version: SC_SNAPSHOT-2012-03-01_v8.2p/Pro Deployment (built 2012-03-01)

    #2
    Just call fetchData() with criteria that selects the first business code, or equivalently, setInitialCriteria() with setAutoFetchData(true).

    This means that, prior to providing the criteria, you'll need to use DataSource.fetchData() to determine what the first business code is; this is just a couple lines of code.

    Comment


      #3
      Thanks for the quick response. You're right, a couple of lines of code did the trick.

      Comment

      Working...
      X