0
votes

I'm writing a TFS/VSTS extension widget which uses the VSTS Combo control (documented here) to display a hierarchical data source. For example: Tree of stored queries.

Populating the tree is quite straight forward, such as in the following simplified code. Note that each source item has a unique id property.

var source = [{ text: 'root',
                  id:1,
                  children: [ {text:'child 1', id:10},
                              {text:'child 2', id:20},
                              {text:'child 3', id:30}
                            ]
                }];

  var treeOptions = {
    type: TreeView.SearchComboTreeBehaviorName,
    width: "350px",
    sepChar: '>',
    source: source,
    change: function () {
      console.log('selected: ' + this.getValue());
    }
  };
  var combo = Controls.create(Combos.Combo, $(".combo-container"), treeOptions);

I have two questions regarding the combo:
1. When the combo selection changes, How do I get the selected item's id (not the text)?
2. Is there a way to allow only leaf selection?

1

1 Answers

0
votes

You can't get the selected item's id directly, you can get the id per to the select text (JSON operation).

It isn't supported to just allow only leaf selection, you may do it with other 3rd control package.