TFS 2012工作项模板复选框

时间:2013-09-18 09:36:40

标签: c# checkbox tfs azure-devops workitem

是否有可用于TFS 2012工作项的复选框控件?我找到了TFS 2010的那个,但由于某种原因它不适用于2012年。

TFS2010工作项复选框

http://social.msdn.microsoft.com/Forums/vstudio/en-US/7e6ee51f-31f9-4859-8e9b-e081400576d7/tfs2010-workitem-checkbox-control

我真的不明白为什么工作项模板中尚未实现复选框控件..

1 个答案:

答案 0 :(得分:2)

我已经编写了自己的Checkbox自定义控件:

manifest.xml文件内容:

<WebAccess version="12.0">
  <plugin name="AzCheckBox Custom Control" vendor="vendorName" moreinfo="http://www.vendorName.be/" version="1.1.1.0" >
    <modules>
      <module namespace="AzCheckBox" kind="TFS.WorkItem.CustomControl"/>
    </modules>
  </plugin>
</WebAccess>

AzCheckBox.js文件内容:

// Register this module as "AzCheckBox" and declare 
// dependencies on TFS.WorkItemTracking.Controls, TFS.WorkItemTr
TFS.module("AzCheckBox",
    [
        "TFS.WorkItemTracking.Controls",
        "TFS.WorkItemTracking",
        "TFS.Core"
    ],
    function () {

        // module content
        var WITOM = TFS.WorkItemTracking,
            WITCONTROLS = TFS.WorkItemTracking.Controls,
            delegate = TFS.Core.delegate;


        // Constructor for AzCheckBox
        function AzCheckBox(container, options, workItemType) {
            this.baseConstructor.call(this, container, options, workItemType);
        }

        AzCheckBox.inherit(WITCONTROLS.WorkItemControl, {
        _control:null, 

        _init: function () {
            this._base();
            this._control = $("<input type='checkbox' >").appendTo(this._container).bind("change", delegate(this, this.onChanged));
            },

        invalidate : function (flushing, field) {
            if(this._workItemControl.isReadOnly()) {
                this._control.attr("disabled", "disabled");
            } else {
                this._control.removeAttr("disabled");
            }
            this._control.attr("checked", field.getValue());
        },

        getValue : function () {
            return this._control.attr("checked") ? true : false;
        },

        clear : function () {
            this._control.attr("checked", false);
        },

        onChanged : function (e) {
            this._workItemControl._getField().setValue(this.getValue());
        },
    });

    WITCONTROLS.registerWorkItemControl("AzCheckBox", AzCheckBox);
        return {AzCheckBox: AzCheckBox};
});