Announcement

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

    Combox Box Forced Selected Item

    I have a comboboxitem where if another control on a form is clicked it needs to be set to a certain value. This comboboxitem has its own datasource that is tied to a LUT. I cannot find a method by which to set the this combo item to a particular index. Is there an example of such a use case out there?

    Thank you

    #2
    Just call setValue() with the index. The ComboBox will automatically use it's optionDataSource to fetch the corresponding display value.

    Comment


      #3
      What method can I use to determine which index in the optionsDataSource the record I want is?

      Code:
      for(int i = 0; i < optionsDataSource.getRecords().length(); i ++)
      {
           Record record = optionsDataSource.records[i];
           if(someCriteria)
           {
               //"foundIt" 
              comboboxitemFoo.setValue(i);
           }
      }
      Last edited by ls3674; 6 Apr 2012, 14:44.

      Comment


        #4
        That seems kind of dubious - unless the dataset is immutable you probably want to use the PK instead.

        But if for some reason you really need the index, do you mean the index according to the current search criteria entered in the ComboBoxItem, or with respect to the whole DataSource?

        If the whole DataSource, that will require a server trip since the client has only some of the data..

        Comment


          #5
          I want to iterate the datasource and find the record. It is unlikely that the dataset will update often, if ever. It's a LUT, but I want to do it dynamically and not assume that I will always know the index or pk of the item I'm looking for.

          Unless I missed something setValue() takes the index no?
          Originally posted by Isomorphic
          Just call setValue() with the index. The ComboBox will automatically use it's optionDataSource to fetch the corresponding display value.
          Last edited by ls3674; 6 Apr 2012, 14:53.

          Comment


            #6
            setValue() takes a value for the valueField. Typically that's the PK.

            It's a little unclear what you want, but:

            1. to get a particular record by index, use DataSource.fetchData() and specify startRow and endRow in the DSRequest properties

            2. to find out the index of a particular record that has a unique value, call DataSource.fetchData() to get the complete dataset, then use RecordList.findIndex() after obtaining the RecordList in the callback. You could also do the equivalent on the server side to avoid loading the whole dataset (and with some fancy SQL could avoid ever loading the whole dataset onto the app server).

            Comment

            Working...
            X