How can I get a combo control of type TreeView.ComboTreeBehaviorName
to have its nodes collapsed by default?
I've tried looking at the documentation here and here, but it seems completely unhelpful to me.
I've also tried inspecting the types (in vss.d.ts) to see if there's a property I can set:
maxAutoExpandDropWidth
which claims that it Specifies the max size when auto-expand drop bigger than combo
, but setting it to 0 or 1 doesn't seem to have any effect. dropOptions?: IComboDropOptions;
but it doesn't seem to
have any properties for expand/collapse either.collapsed: true
to the IComboOptionsControls.Enhancement.enhance
method seems to
suggest that I can pass some options as part of the type
property
on the IComboOptions
, but I tried that and couldn't do it because
the type
property wants a string, not an object.node.expanded = false
for all nodes before passing the tree
to the source
propertyHere are some relevant code excerpts:
import * as Controls_Combos from "VSS/Controls/Combos";
import * as Controls from "VSS/Controls";
import * as TreeView from "VSS/Controls/TreeView";
this._$areaInput = $("<input type='text' id='inputAreaPicker' />")
.val(someValueThatDoesnotMatter)
.bind("blur", (e) => {
this._updateSomeOtherField();
this._validate();
});
}
...
<Controls_Combos.Combo>Controls.Enhancement.enhance(
Controls_Combos.Combo,
this._$areaInput,
<Controls_Combos.IComboOptions> {
type: TreeView.ComboTreeBehaviorName,
source: ConvertToTreeNodes(someItems), // loads multi-level tree successfully
mode: 'drop',
allowEdit: false,
maxAutoExpandDropWidth: 1, // seems to have no effect
collapsed: true // no effect
}
);
export function ConvertToTreeNodes(items): TreeView.TreeNode[] {
// let _this = this;
return $.map(items, function (item) {
let node = new TreeView.TreeNode(item.name);
node.id = item.id;
if (item.children && item.children.length > 0) {
node.addRange(ConvertToTreeNodes(item.children));
}
node.expanded = false;
return node;
});
}
The answer is an undocumented property called 'treeLevel':
<Controls_Combos.Combo>Controls.Enhancement.enhance(
Controls_Combos.Combo,
this._$areaInput,
<Controls_Combos.IComboOptions> {
type: TreeView.ComboTreeBehaviorName,
source: ConvertToTreeNodes(someItems),
mode: 'drop',
allowEdit: false,
treeLevel: 0 // collapse to first level by default
}
);