Exemplo n.º 1
0
        public override void WriteInitializationScript(System.IO.TextWriter writer)
        {
            IClientSideObjectWriter objectWriter = ClientSideObjectWriterFactory.Create(Id, "tAutoComplete", writer);

            objectWriter.Start();

            objectWriter.Append("autoFill", AutoFill, false);
            objectWriter.Append("highlightFirst", HighlightFirstMatch, false);

            if (!defaultEffects.SequenceEqual(Effects.Container))
            {
                objectWriter.Serialize("effects", Effects);
            }

            ClientEvents.SerializeTo(objectWriter);
            Multiple.SerializeTo(objectWriter);

            DataBinding.Ajax.SerializeTo <AutoCompleteBindingSettings>("ajax", objectWriter, this);
            DataBinding.WebService.SerializeTo <AutoCompleteBindingSettings>("ws", objectWriter, this);

            objectWriter.Append("filter", Filtering.FilterMode == AutoCompleteFilterMode.Contains ? 2 : 1); //"contains" : "startsWith");
            objectWriter.Append("minChars", Filtering.MinimumChars, 1);

            if (Items.Any())
            {
                objectWriter.AppendCollection("data", Items);
            }

            if (DropDownHtmlAttributes.Any())
            {
                objectWriter.Append("dropDownAttr", DropDownHtmlAttributes.ToAttributeString());
            }

            objectWriter.Append("encoded", this.Encoded, true);

            objectWriter.Complete();

            base.WriteInitializationScript(writer);
        }