我正在开发TFS 2012 web访问自定义控件,单击保存工作项按钮时,我需要更改某些工作项字段值。
我刚刚为Visual Studio开发了相同的自定义控件,并在IWorkItemControl.FlushToDatasource方法中执行了这些更改,但我不知道如何在web访问控制中实现相同的更改。
在保存工作项时,我尝试更改无效函数中的工作项字段值。
invalidate: function (flushing) {
if (this._workItem.isSaving()) {
this._workItem.getField("FieldName").setValue("newValue");
}
},
但是它不起作用,尽管在保存工作项时所做的更改包含在已更新字段的列表中,但它们不会保存。
你知道如何使用Javascript API来实现它吗?
谢谢。
奥斯卡
发布于 2017-07-12 13:47:12
你能试试这个吗:
_control: null,
_init: function() {
alert("_init() called!");
debugger;
if (this._workItem) {
var originalEstimate = this._workItem.getField("Microsoft.VSTS.Scheduling.OriginalEstimate").getValue();
alert('OriginalEstimate value is ' + originalEstimate);
console.log('this in _init');
console.log(this);
} else {
alert('_workItem is null or undefined!');
console.log('this in _init');
console.log(this);
}
this._base();
this._control = $("<div style='width:100%;height:100%;background-color:lightblue;'><button type='submit'>CLICK ME!</button></div>").appendTo(this._container).bind("click", delegate(this, this._onClick));
},
invalidate: function(flushing) {
alert("invalidate(flushing) called!");
var value = this._getField().getValue();
debugger;
if (this._workItem) {
var originalEstimate = this._workItem.getField("Microsoft.VSTS.Scheduling.OriginalEstimate").getValue();
alert('OriginalEstimate value is ' + originalEstimate);
console.log('this in _init');
console.log(this);
} else {
alert('_workItem is null or undefined!');
console.log('this in _init');
console.log(this);
}
alert(value);
},
clear: function() {
alert("clear() called!");
},
_onClick: function() {
alert("Butona tıklandı!");
}
https://stackoverflow.com/questions/18758148
复制