Announcement

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

    Disable SelectItem choices (Pro version)

    Hi, I've seen a couple of threads related to this, but it's still not clear to me.

    I'm loading int-string pairs via an SQL datasource and choosing one of them from a SelectItem (valueField is the integer, displayField is the string). I'd like to disable or remove some of these programmatically, based on some other values in form.

    I've seen mention of PickList, pickListAttributes, criteria, etc. Could you point me to a clear example or provide the methods or structure (inheritance/override?) required to do so?

    Thanks in advance!

    #2
    setPickListCriteria() is what you want to check out. Here is a small code sample, just using a showcase example with the country DS, nothing fancy.

    Code:
    public void onModuleLoad() {
      DynamicForm form = new DynamicForm();
      final ComboBoxItem itemName = new ComboBoxItem("itemName");
      itemName.setTitle("Item Name");  
      itemName.setPickListWidth(250);  
      itemName.setOptionDataSource(CountryDS.getInstance());
      itemName.setDisplayField("countryName");
      itemName.setValueField("countryName");
    
      ButtonItem filter = new ButtonItem("filter");
      filter.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
          itemName.setPickListCriteria(new Criteria("countryCode", "US"));
        }
      }) ;  
    		         
      form.setItems(itemName, filter);  
      form.draw();
    }

    Comment


      #3
      This was very helpful. Thanks very much!

      Comment

      Working...
      X