protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); if (Terms != null) { Attributes.Add("SelectedTerms", String.Join(",", Terms.Select(t => t.TermId.ToString()).ToArray())); } Attributes.Add("IncludeSystemVocabularies", IncludeSystemVocabularies.ToString().ToLowerInvariant()); Attributes.Add("IncludeTags", IncludeTags.ToString().ToLowerInvariant()); Attributes.Add("PortalId", PortalId.ToString()); }
protected override void OnInit(EventArgs e) { base.OnInit(e); if (!string.IsNullOrEmpty(CssClass)) { CssClass = string.Format("{0} TermsSelector", CssClass); } else { CssClass = "TermsSelector"; } var includeSystem = IncludeSystemVocabularies.ToString().ToLowerInvariant(); var includeTags = IncludeTags.ToString().ToLowerInvariant(); var apiPath = Globals.ResolveUrl($"~/API/InternalServices/ItemListService/GetTerms?includeSystem={includeSystem}&includeTags={includeTags}&q="); Options.Preload = "focus"; Options.Plugins.Add("remove_button"); Options.Render = new RenderOption { Option = "function(item, escape) {return '<div>' + item.text + '</div>';}" }; Options.Load = $@"function(query, callback) {{ $.ajax({{ url: '{apiPath}' + encodeURIComponent(query), type: 'GET', error: function() {{ callback(); }}, success: function(data) {{ callback(data); }} }}); }} "; Options.Items = _initOptions; }