1

I am trying to change the text displayed in the textbox after adding visual. See code below.

Based on the documentation I can only interact with the Visual Properties or Data Fields.

The textbox visual does not have any data roles when I am running getCapabilities() on it. In the visual properties list, the titleText seems to be the property I am looking for, but it does not change anything.

To give some context why I need this. I am trying to build a form, where I can add extra visuals to an already existing PowerBI report, and I need the abilty to also set some basic formatted text there to have a nicely looking layout

    const pages = await report?.getPages()

    const activePage = pages?.filter(function (page: any) {
      return page.isActive
    })[0]

    const visualResponse = await activePage?.createVisual(
      'textbox',
      {
        displayState: {
          mode: models.VisualContainerDisplayMode.Visible,
        },
        height: 100,
        width: 100,
        x: 100,
        y: 100,
      },
      true,
    )

    visualResponse?.visual.setProperty(
      {
        objectName: 'title',
        propertyName: 'titleText',
      },
      {
        value: 'Some text to display',
      },
    )

1 Answer 1

2

Along with the titleText propertyName, We also need to set the visible propertName to be true for title to be visible.

Refer to the below code.

visualResponse?.visual.setProperty(
    {
        objectName: 'title',
        propertyName: 'titleText',
    },
    {
        value: 'Some text to display',
    },
)
visualResponse?.visual.setProperty(
    {
        objectName: 'title',
        propertyName: 'visible',
    },
    {
        value: true,
    },
)
  

References:

title-PropertyNames

Properties-API

Sign up to request clarification or add additional context in comments.

1 Comment

You were correct, that applies to the title text. However, it works slightly differently than I expected. My goal is to be able to insert and format text in the textbox (its value). I think I could just use the title property, but this won't allow me to use the partial formatting

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.