public override void Visit(ComboBoxHtmlRenderer <TModel, TValue> comboBox)
        {
            var configuration         = comboBox.Configuration;
            var urlParameterContainer = ConfigureUrlAndParameter(configuration);

            var cascadeFromMetadata = ModelMetadata.FromLambdaExpression(configuration.CascadeFromExpression, configuration.HtmlHelper.ViewData);
            var cascadeFrom         = string.Format("{0}{1}", cascadeFromMetadata.PropertyName, configuration.Index);

            var value = AttributeConfigurator.GetValueFromMetaData(configuration);

            if (value == Guid.Empty.ToString())
            {
                value = string.Empty;
            }

            var attributes = AttributeConfigurator.SetBaseAttribute(configuration);

            attributes["url"]         = urlParameterContainer.Url;
            attributes["controltype"] = "kendoComboBoxForCustomDataLinkedFor";
            attributes["parameter"]   = urlParameterContainer.Parameter;
            attributes["cascadeFrom"] = cascadeFrom;

            var combox = configuration.HtmlHelper.TextBox(ExpressionHelper.GetExpressionText(configuration.TargetExpression), value, attributes).ToString();

            ComboBox = new MvcHtmlString(combox);
        }
        private IComboBoxVisitor <TModel, TValue> GetVisitorFromControlType(string controlType)
        {
            //TODO create visitor factory
            var attributeConfigurator = new AttributeConfigurator <TModel, TValue>();
            var visitorDictionary     = new Dictionary <string, IComboBoxVisitor <TModel, TValue> >
            {
                { ControlTypeConstant.KendoComboBox, new RegularVisitor <TModel, TValue>(attributeConfigurator) },
                { ControlTypeConstant.KendoComboBoxLinked, new LinkedForVisitor <TModel, TValue>(attributeConfigurator) },
                { ControlTypeConstant.KendoComboBoxForCustomData, new CustomDataVisitor <TModel, TValue>(attributeConfigurator) },
                { ControlTypeConstant.KendoComboBoxForCustomDataLinkedFor, new CustomDataLinkedForVisitor <TModel, TValue>(attributeConfigurator) }
            };

            var visitor = visitorDictionary.Single(o => o.Key.Equals(controlType));

            return(visitor.Value);
        }
Пример #3
0
        public override void Visit(ComboBoxHtmlRenderer <TModel, TValue> comboBox)
        {
            var configuration = comboBox.Configuration;
            var value         = AttributeConfigurator.GetValueFromMetaData(configuration);

            //Note Temporary Fixed For not nullable guid.
            if (value == Guid.Empty.ToString())
            {
                value = string.Empty;
            }
            var attributes = AttributeConfigurator.SetBaseAttribute(configuration);

            attributes["service"]     = configuration.DataSource as string;
            attributes["controltype"] = "kendoComboBox";

            var combox = configuration.HtmlHelper.TextBox(ExpressionHelper.GetExpressionText(configuration.TargetExpression), value, attributes).ToString();

            ComboBox = new MvcHtmlString(combox);
        }
Пример #4
0
        public override void Visit(ComboBoxHtmlRenderer <TModel, TValue> comboBox)
        {
            var configuration         = comboBox.Configuration;
            var urlParameterContainer = ConfigureUrlAndParameter(configuration);
            var value = AttributeConfigurator.GetValueFromMetaData(configuration);

            if (value == Guid.Empty.ToString())
            {
                value = string.Empty;
            }

            var attributes = AttributeConfigurator.SetBaseAttribute(configuration);

            attributes["url"]         = urlParameterContainer.Url;
            attributes["controltype"] = "kendoComboBoxForCustomData";
            attributes["parameter"]   = urlParameterContainer.Parameter;

            var combox = configuration.HtmlHelper.TextBox(ExpressionHelper.GetExpressionText(configuration.TargetExpression), value, attributes).ToString();

            ComboBox = new MvcHtmlString(combox);
        }
 protected AsbtractVisitorTemplate(AttributeConfigurator <TModel, TValue> attributeConfigurator)
 {
     AttributeConfigurator = attributeConfigurator;
 }
Пример #6
0
 public LinkedForVisitor(AttributeConfigurator <TModel, TValue> attributeConfigurator) : base(attributeConfigurator)
 {
 }
Пример #7
0
 public RegularVisitor(AttributeConfigurator <TModel, TValue> attributeConfigurator) : base(attributeConfigurator)
 {
 }
Пример #8
0
 public CustomDataVisitor(AttributeConfigurator <TModel, TValue> attributeConfigurator) : base(attributeConfigurator)
 {
 }