如何让 vss sdk treeview 默认折叠?

How do I get vss sdk treeview to collapse by default?

如何让 TreeView.ComboTreeBehaviorName 类型的组合控件默认折叠其节点?

我已经尝试查看文档 here and here,但它似乎对我完全没有帮助。

我还尝试检查类型(在 vss.d.ts 中)以查看是否有 属性 我可以设置:

以下是一些相关的代码摘录:

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;
    });
}

答案是一个未记录的 属性,名为 '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

            }
        );

I've requested that it be documented