问题
I added new work item to tfs. for example work item type: cab, states: new, active, closed.
I added field and form element to form layout. for example customer note (type: string)
added readonly field rule on active state in process template workflow.
But it is hidden when I did'nt input text with change new to active.
why? I want to visible my field even so I did not input data.
how can I do?
thanks
回答1:
Here's the rules on ReadOnly fields for VS 2012 going forward. Note that this was NOT the behavior for VS 2010 and before. This is unfortunately undocumented and IMHO counter-intuitive.
- If a field is ReadOnly AND Empty, it will disappear from the form
- If it is only ReadOnly BUT has a value, it will still be on the form but not editable.
For example, the PBI work item has a condition that when it goes into the “Done” state, it makes both the “Business Value” and Effort field go ReadOnly as shown in the XML below from its Work Item Type Definition (WITD):
<STATE value="Done">
<FIELDS>
<FIELD refname="Microsoft.VSTS.Common.BusinessValue">
<READONLY />
</FIELD>
<FIELD refname="Microsoft.VSTS.Scheduling.Effort">
<READONLY />
</FIELD>
</FIELDS>
</STATE>
This forum post speaks to the behavior somewhat as well. Also, when you use the “EMPTY” attribute on a work item field, it will disappear from the form and wouldn’t you know it, “EMPTY” is a combo of “READONLY” and emptying out the field. So it all makes sense, kinda, in the end. :)
回答2:
- For the old form layout (TFS 2015 and prior): Add the "HideReadOnlyEmptyFields" attribute to the Layout tag and set it to false.
<FORM>
<Layout HideReadOnlyEmptyFields="false">
...
- For the new web layout: As of TFS 2018, you can add a "ShowEmptyReadOnlyFields" attribute to the WebLayout tag and set it to true.
<WebLayout ShowEmptyReadOnlyFields="true">
...
来源:https://stackoverflow.com/questions/23295946/how-to-readonly-of-the-tfs-work-item-field-but-not-hidden