5

I'm trying to extend the experience analytics filters component by adding new custom filters that will be used for my custom reports, my question is: How I can create a textbox field using the following class?:

Sitecore.ExperienceAnalytics.Client.RenderingHelper

What I can find methods to create different controls but I can't find a method create a text field.

Following is an example of creating combo box with two buttons:

helper.MakeComboBox("EventTypeComboBox", controlsRow, options ?? new List<ComboBoxItem>()
                                   {
                                       new ComboBoxItem()
                                   });


helper.MakeButton("SubmitButton", controlsRow, Globals.System.Texts.Apply.Guid.ToString(), "Primary");
helper.MakeButton("ResetButton", controlsRow, Globals.System.Texts.RevertFiltersToStandard.Guid.ToString());

Any Ideas?

0

Rendering text

Try using:

helper.MakeText(
    string controlId, string parent, string text,
    TextType textType = TextType.Text, string isVisible = "True")

TextType enum is defined as follows:

 enum TextType
  {
    Text, Label, HelpLabel, LargeLabel, Value,
    LargeValue, LargeTitle, Title, SmallTitle,  Divider
  }

You can play around with different types of text to create different labels/titles/etc.

Rendering text box

From Mohammed's comment:

I managed to do it by the following code:

string str = renderingId + "EventTopic"; 
this.Html.Sitecore().AddContentToPlaceholder(controlsRow + ".Content", 
this.Html.Sitecore().Controls().Rendering(this.Html, 
    "{57F86E9A-1844-45CE-BF8A-62900AE17A92}", str, "", null)
    .ToHtmlString())

Generic helper

If that doesn't fit your requirement you can always use a generic method:

helper.CreateRenderingAt(
        string renderindItemId, string controlId, 
        string parent, object parameters = null, 
        string datasource = "", string contentPlaceholder = ".Content")

The renderindItemId parameter is an ID of the actual rendering from the component library (from CORE database) that you want to be rendered.

For example, if you want to render the text using the generic method, it would look like that:

helper.CreateRenderingAt(Globals.Bcl.Renderings.Common.Text, 
    controlId, parent, (object) new
      {
        TextType = textType,
        Text = text,
        IsVisible = isVisible
      }, "", ".Content");

In that method call the Globals.Bcl.Renderings.Common.Text constant value is {7717EB6C-9F90-4C58-826D-5E87722A0318}.

More

You can always decompile the Sitecore.ExperienceAnalytics.Client.dll to find more clues on how they render different components.

  • I already did that, I tried MakeText method with different enumeration, This method render a text, what I need is a textbox, none of them worked for me. – Mohammed Syam Jan 10 '17 at 21:30
  • 1
    There is no overload for textbox in the helper. Try passing a textbox rendering ID to the generic method – Andrey Bobrov Jan 10 '17 at 21:31
  • I managed to do thing by the following code: string str = renderingId + "EventTopic"; this.Html.Sitecore().AddContentToPlaceholder(controlsRow + ".Content", this.Html.Sitecore().Controls().Rendering(this.Html, "{57F86E9A-1844-45CE-BF8A-62900AE17A92}", str, "", null).ToHtmlString()); Please add this to your answer for a better formatting. – Mohammed Syam Jan 11 '17 at 13:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.