I have some problems with the fact that when I select a value in the dropbox, or rather steel a checkmark, then it is automatically reset.
[Serializable]
public class KNRWCSAttributeExt : PXCacheExtension<CSAttribute>
{
public static bool IsActive() => true;
#region UsrSchemaField
[PXDBString(512, InputMask = "", IsUnicode = true)]
[PXUIField(DisplayName = "Multi Schema Field")]
//[PXUIVisible(typeof(Where<PX.CS.CSAttribute.controlType, Equal<CSAttribute.AttrType.giSelector>>))]
[PXStringList(new string[] {null}, new string[] {""}, ExclusiveValues = false)]
public virtual string UsrSchemaField { get; set; }
public abstract class usrSchemaField : PX.Data.BQL.BqlString.Field<usrSchemaField>
{
}
#endregion
}
I assume that this is due to the fact that the event is triggered again and the array is filled over and over again. With the usual examples that are already described on stackoverflow it works, but my code does not work
Tell me please how I can get data into DropDown once so that I can then select and the value is not reset.
public class KNRWCSAttributeMaintExt : PXGraphExtension<CSAttributeMaint>
{
public static bool IsActive() => true;
protected virtual void _(Events.RowSelected<CSAttribute> e)
{
if (e.Row == null)
{
return;
}
var el = e.Row as CSAttribute;
if (el.ControlType == CSAttribute.GISelector)
{
if (!string.IsNullOrEmpty(e.Row.ObjectName as string))
{
Type objType = System.Web.Compilation.PXBuildManager.GetType(e.Row.ObjectName, true);
PXCache objCache = Base.Caches[objType];
var fields = objCache.Fields
.Where(f => objCache.GetBqlField(f) != null ||
f.EndsWith("_Attributes", StringComparison.OrdinalIgnoreCase))
.Where(f => !objCache.GetAttributesReadonly(f).OfType<PXDBTimestampAttribute>().Any())
.Where(f => !string.IsNullOrEmpty((objCache.GetStateExt(null, f) as PXFieldState)?.ViewName))
.Where(f => f != "CreatedByID" && f != "LastModifiedByID")
.ToArray();
PXStringListAttribute.SetList<KNRWCSAttributeExt.usrSchemaField>(e.Cache, e.Row, fields, fields);
}
}
}
}
View
<asp:Content ID="cont2" ContentPlaceHolderID="phF" runat="Server">
<px:PXFormView ID="form" runat="server" DataSourceID="ds" Style="z-index: 100" Width="100%" DataMember="Attributes" Caption="Attribute Summary">
<Template>
<px:PXLayoutRule runat="server" StartColumn="True" ControlSize="M" LabelsWidth="SM" />
<px:PXSelector ID="edAttributeID" runat="server" DataField="AttributeID" AutoRefresh="True" DataSourceID="ds">
<GridProperties FastFilterFields="description" />
</px:PXSelector>
<px:PXTextEdit ID="edDescription" runat="server" AllowNull="False" DataField="Description" />
<px:PXDropDown CommitChanges="True" ID="edControlType" runat="server" AllowNull="False" DataField="ControlType" />
<px:PXCheckBox ID="chkIsInternal" runat="server" DataField="IsInternal" />
<px:PXCheckBox ID="chkContainsPersonalData" runat="server" DataField="ContainsPersonalData" />
<px:PXTextEdit ID="edEntryMask" runat="server" DataField="EntryMask" />
<px:PXTextEdit ID="edRegExp" runat="server" DataField="RegExp" />
<px:PXSelector ID="SchemaObject" runat="server" DataField="ObjectName" AutoRefresh="True" CommitChanges="true" />
<px:PXDropDown ID="SchemaField" runat="server" DataField="FieldName" AutoRefresh="True" CommitChanges="True" />
<px:PXDropDown ID="edRegExpMultiSelect" runat="server" AllowMultiSelect="true" DataField="UsrSchemaField" CommitChanges="True"/>
</Template>
</px:PXFormView>
</asp:Content>