我有以下用例:
Acumatica下拉列表,可以有2个左右的值。
e.g:
- 如果用户选择选项a,我需要显示PXPanel(ID =" panel1")
- 如果用户选择选项b,我需要显示PXPanel(ID =" panel2")
那些PXPanels位于一个PXFormView中,所以他们有一个DataMember像这样:
function updateInput(value, elem, min, max) {
if (value > min - 1 && value < max + 1) {
if (value < elem.childElementCount) {
var oldVal = (value - elem.childElementCount) * -1;
for (var i = 0; i < oldVal; i++) {
elem.removeChild(elem.childNodes[elem.childElementCount - 1]);
}
} else {
var children = elem.childElementCount
var newVal = value; - elem.childElementCount;
for (var j = 0; j < newVal; j++) {
var newElem = document.createElement("input");
newElem.setAttribute("type", "text");
newElem.setAttribute("name", "item" + (children - j + 1)); elem.appendChild(newElem);
}
}
}
}
是否可以有条件地显示/隐藏PXPanels?
正如RuslanDev所说,我可以用PXLayoutRule(GroupCaption)达到同样的效果,但在这种情况下,我不能将标题设置为100%,它等于第一列的宽度。< / p>
使用PXPanel:
<px:PXFormView ID="form" runat="server" DataSourceID="ds" DataMember="Waybills">
<px:PXPanel ID="panel1" ..
<px:PXPanel ID="panel2" ..
</px:PXFormView>
使用PXLayoutRule:
apsx:
<px:PXPanel ID="panel3" runat="server" Caption="Buyer (Receiver)" RenderStyle="Fieldset" AlreadyLocalized="False" DataMember="" >
<px:PXLayoutRule runat="server" StartRow="True" StartColumn="True" ColumnWidth="XM" />
<px:PXSegmentMask CommitChanges="True" ID="edCustomerID" runat="server" DataField="CustomerID" DataSourceID="ds" />
<px:PXLayoutRule runat="server" StartRow="True" StartColumn="True" ColumnWidth="XM" />
<px:PXTextEdit ID="edRecipientTaxRegistrationID" runat="server" DataField="RecipientTaxRegistrationID" Enabled="False" CommitChanges="True" AlreadyLocalized="False" DefaultLocale="" />
<px:PXCheckBox ID="edRecipientIsForeignCitizen" runat="server" DataField="RecipientIsForeignCitizen" AlreadyLocalized="False" Enabled="false"/>
<px:PXLayoutRule runat="server" StartColumn="True" ColumnWidth="XM" />
<px:PXTextEdit ID="edRecipientName" runat="server" DataField="RecipientName" Enabled="False" AlreadyLocalized="False" DefaultLocale="" />
<px:PXLayoutRule runat="server" StartColumn="True" ColumnWidth="XM" />
<px:PXTextEdit ID="edRecipientDestinationAddress" runat="server" DataField="RecipientDestinationAddress" CommitChanges="True" AlreadyLocalized="False" DefaultLocale="" />
</px:PXPanel>
答案 0 :(得分:1)
除了有条件地将可见设置为 true 或 false之外,没有选项可以隐藏整个业务逻辑中的PXPanel ,用于放置在PXPanel中的每个输入控件:
protected virtual void ARFinCharge_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
{
ARFinCharge fin = e.Row as ARFinCharge;
if (fin == null) return;
PXUIFieldAttribute.SetVisible<ARFinCharge.fixedAmount>(cache, fin, fin.ChargingMethod == OverdueChargingMethod.FixedAmount);
PXUIFieldAttribute.SetVisible<ARFinCharge.lineThreshold>(cache, fin, fin.ChargingMethod == OverdueChargingMethod.PercentWithThreshold);
PXUIFieldAttribute.SetVisible<ARFinCharge.minFinChargeAmount>(cache, fin, fin.ChargingMethod == OverdueChargingMethod.PercentWithMinAmount);
}
对于PXLayoutRule方法,请使用如下的Aspx布局(客户选择器必须跨越其下方的3列):
<px:PXLayoutRule runat="server" StartRow="True" StartGroup="true" GroupCaption="Buyer (Receiver)" />
<px:PXSegmentMask CommitChanges="True" ID="edCustomerID" runat="server" DataField="CustomerID" />
<px:PXLayoutRule runat="server" Merge="True" />
<px:PXTextEdit ID="edRecipientTaxRegistrationID" Size="M" runat="server" DataField="RecipientTaxRegistrationID" Enabled="False" CommitChanges="True" AlreadyLocalized="False" DefaultLocale="" />
<px:PXTextEdit ID="edRecipientName" runat="server" Size="M" DataField="RecipientName" Enabled="False" AlreadyLocalized="False" DefaultLocale="" />
<px:PXTextEdit ID="edRecipientDestinationAddress" Size="M" runat="server" DataField="RecipientDestinationAddress" CommitChanges="True" AlreadyLocalized="False" DefaultLocale="" />
<px:PXLayoutRule runat="server" Merge="False" />
<px:PXCheckBox ID="edRecipientIsForeignCitizen" runat="server" DataField="RecipientIsForeignCitizen" AlreadyLocalized="False" Enabled="false"/>
<px:PXLayoutRule runat="server" EndGroup="true" />
答案 1 :(得分:0)
使用PXFormView而不是PXPanel解决了所有问题。