public LOSSpinEditExtension SpinEditFor <TValueType>(Expression <Func <ModelType, TValueType> > expression, Action <LOSSpinEditSettings> method)
        {
            HttpUtils.SetContextValue <HtmlHelper>("DXHtmlHelper", HtmlHelper);
            var settingInstance = new LOSSpinEditSettings
            {
                Name = ExtensionsHelper.GetFullHtmlFieldName(expression)
            };

            method?.Invoke(settingInstance);
            var modelMetadata     = ModelMetadata.FromLambdaExpression(expression, HtmlHelper.ViewData);
            var spinEditComponent = new LOSSpinEditExtension(settingInstance, HtmlHelper.ViewContext, modelMetadata);

            //spinEditComponent.DoAnythingAfterApplySettings();
            return(spinEditComponent);
        }
Пример #2
0
        internal void DoAnythingAfterApplySettings(LOSSpinEditSettings settings)
        {
            settings.AutoCompleteType = System.Web.UI.WebControls.AutoCompleteType.None;
            //Reading Custom attribute
            var          modelType    = Metadata.ContainerType;
            PropertyInfo propertyInfo = modelType.GetProperty(base.Metadata.PropertyName);

            if (propertyInfo != null)
            {
                var numberPrecisionAttribute = propertyInfo.GetCustomAttributes(typeof(NumberPrecisionAttribute), true).FirstOrDefault() as NumberPrecisionAttribute;
                if (numberPrecisionAttribute != null)
                {
                    settings.Properties.MaxTotalNumber             = numberPrecisionAttribute.MaxDigits;
                    settings.Properties.MaxNumberAfterDecimalPoint = numberPrecisionAttribute.MaxDigitAfterPoint;
                }
                if (Metadata.Model != null)
                {
                    settings.Properties.SimpleValue = decimal.Parse(base.Metadata.Model.ToString());
                }
            }
            settings.Properties.Prepare();
        }