acumatica
ड्रॉपडाउन सूची में आइटम संशोधित करना
खोज…
परिचय
इस विषय में आप सीखेंगे कि PXStringList या PXIntList विशेषताओं से विरासत में मिली फ़ील्ड विशेषताओं को कैसे संशोधित किया जाए। प्रदर्शन किया गया दृष्टिकोण आधार एक्यूमैटा ईआरपी उत्पाद की कार्यक्षमता को नहीं तोड़ना सुनिश्चित करेगा और एक्यूमेटा के नए संस्करण के लिए अपने अनुकूलन को अपग्रेड करते समय न्यूनतम रखरखाव की आवश्यकता होगी।
टिप्पणियों
उपरोक्त सभी नमूनों में, आपने _AllowedValues
और _AllowedLabels
सरणियों दोनों में परिवर्तन किए हैं। यदि आपका कार्य ड्रॉप-डाउन आइटम के केवल लेबल (बाह्य मान) को संशोधित करना है, तो अनुवाद शब्दकोश का उपयोग करने पर विचार करें। अनुवाद शब्दकोशों की अधिक जानकारी के लिए एक्युमैटिक ईआरपी प्रलेखन देखें
वैवाहिक विधियों को संशोधित करना
इस उदाहरण में आप संपर्क फ़ॉर्म (CR302000) पर पाए गए वैवाहिक स्थिति ड्रॉप-डाउन सूची को संशोधित करेंगे:
PXStringListAttribute उत्तराधिकारी में नए आइटम जोड़ने के लिए
PXStringList या PXIntList विशेषता से विरासत में मिली विशेषता के अंदर ड्रॉप-डाउन आइटम को हार्ड-कोडित करने का सबसे अच्छा तरीका है कि आपके कस्टम फ़ील्ड विशेषता के निर्माता में _AllowedValues
और _AllowedLabels
सरणियों का आकार बढ़ाना है:
[PXLocalizable(Messages.Prefix)]
public static class MaritalStatusesMessages
{
public const string CommonLaw = "Living common law";
public const string Separated = "Separated (not living common law)";
public const string DivorcedNoCommonLaw = "Divorced (not living common law)";
public const string NeverMarried = "Never Married";
}
public class MaritalStatusesCst1Attribute : MaritalStatusesAttribute
{
public const string CommonLaw = "L";
public const string Separated = "P";
public const string NeverMarried = "N";
public MaritalStatusesCst1Attribute()
{
Array.Resize(ref _AllowedValues, _AllowedValues.Length + 3);
_AllowedValues[_AllowedValues.Length - 3] = CommonLaw;
_AllowedValues[_AllowedValues.Length - 2] = Separated;
_AllowedValues[_AllowedValues.Length - 1] = NeverMarried;
Array.Resize(ref _AllowedLabels, _AllowedLabels.Length + 3);
_AllowedLabels[_AllowedLabels.Length - 3] = MaritalStatusesMessages.CommonLaw;
_AllowedLabels[_AllowedLabels.Length - 2] = MaritalStatusesMessages.Separated;
_AllowedLabels[_AllowedLabels.Length - 1] = MaritalStatusesMessages.NeverMarried;
}
}
ऊपर के नमूने में, आपने वैवाहिक स्थिति ड्रॉप-डाउन सूची में 3 अतिरिक्त आइटम जोड़ने के लिए _AllowedValues
और _AllowedLabels
सरणियों का आकार बढ़ा दिया है। आंतरिक मान, _AllowedValues
सरणी में संग्रहीत, DAC फ़ील्ड्स को असाइन किया जाएगा और डेटाबेस में सहेजा जाएगा, और _AllowedValues
सरणी से बाहरी मान UI में आंतरिक मानों का प्रतिनिधित्व करेंगे।
परिणाम, संपर्क डीएसी विस्तार में परीक्षण करने के लिए, साथ MaritalStatus क्षेत्र को सजाने MaritalStatusesCst1Attribute
:
public class ContactExt : PXCacheExtension<Contact>
{
[PXRemoveBaseAttribute(typeof(MaritalStatusesAttribute))]
[PXMergeAttributes(Method = MergeMethod.Append)]
[MaritalStatusesCst1]
public string MaritalStatus { get; set; }
}
अब वैवाहिक स्थिति ड्रॉप-डाउन सूची में 7 आइटम हैं:
PXStringListAttribute उत्तराधिकारी में घोषित आइटम हटाने के लिए
विशिष्ट ड्रॉप-डाउन आइटम को निकालने के लिए, जो PXStringList या PXIntList विशेषता से विरासत में मिली विशेषता के अंदर हार्ड-कोडित था, आपको अपने कस्टम फ़ील्ड विशेषता के निर्माता में _AllowedValues
और _AllowedLabels
आकार को कम करने की आवश्यकता है:
public class MaritalStatusesCst2Attribute : MaritalStatusesCst1Attribute
{
public MaritalStatusesCst2Attribute()
{
string[] allowedValues = new string[_AllowedValues.Length - 1];
string[] allowedLabels = new string[_AllowedLabels.Length - 1];
Array.Copy(_AllowedValues, 1, allowedValues, 0, _AllowedValues.Length - 1);
Array.Copy(_AllowedLabels, 1, allowedLabels, 0, _AllowedValues.Length - 1);
_AllowedValues = allowedValues;
_AllowedLabels = allowedLabels;
}
}
ऊपर के नमूने में, आपने वैवाहिक स्थिति ड्रॉप-डाउन सूची से एकल आइटम को हटाने के लिए _AllowedValues
और _AllowedLabels
सरणियों का आकार घटा दिया।
परिणाम, संपर्क डीएसी विस्तार में परीक्षण करने के लिए, साथ MaritalStatus क्षेत्र को सजाने MaritalStatusesCst2Attribute
:
public class ContactExt : PXCacheExtension<Contact>
{
[PXRemoveBaseAttribute(typeof(MaritalStatusesAttribute))]
[PXMergeAttributes(Method = MergeMethod.Append)]
[MaritalStatusesCst2]
public string MaritalStatus { get; set; }
}
अब केवल 6 आइटम हैं: 3 मूल और 3 कस्टम - वैवाहिक स्थिति ड्रॉप-डाउन सूची में:
PXStringListAttribute उत्तराधिकारी में घोषित मदों को बदलने के लिए
विशिष्ट ड्रॉप-डाउन आइटम को बदलने के लिए, मूल रूप से PXStringList या PXIntList विशेषता से विरासत में मिली विशेषता के अंदर हार्ड-कोडित, आपको अपने कस्टम फ़ील्ड विशेषता के निर्माण में _AllowedValues
और _AllowedLabels
में उचित मूल्य अपडेट करने की आवश्यकता है:
public class MaritalStatusesCst3Attribute : MaritalStatusesCst2Attribute
{
public const string DivorcedNoCommonLaw = "V";
public MaritalStatusesCst3Attribute()
{
_AllowedValues[Array.IndexOf(_AllowedValues, Divorced)] = DivorcedNoCommonLaw;
_AllowedLabels[Array.IndexOf(_AllowedLabels, Messages.Divorced)] = MaritalStatusesMessages.DivorcedNoCommonLaw;
}
}
ऊपर के नमूने में, आपने क्रमशः _AllowedValues
और _AllowedLabels
सरणियों में D - तलाकशुदा आइटम को V - तलाकशुदा (सामान्य कानून नहीं रह रहा है) के साथ बदल दिया। ऐसा करने से, हम ड्रॉप-डाउन आइटम के आंतरिक और बाहरी दोनों मानों को बदल देते हैं।
परिणाम, संपर्क डीएसी विस्तार में परीक्षण करने के लिए, साथ MaritalStatus क्षेत्र को सजाने MaritalStatusesCst3Attribute
:
public class ContactExt : PXCacheExtension<Contact>
{
[PXRemoveBaseAttribute(typeof(MaritalStatusesAttribute))]
[PXMergeAttributes(Method = MergeMethod.Append)]
[MaritalStatusesCst3]
public string MaritalStatus { get; set; }
}
अब केवल 6 आइटम हैं: 2 मूल, 3 कस्टम और 1 प्रतिस्थापित - वैवाहिक स्थिति ड्रॉप-डाउन सूची में: