Forum Discussion

joao_pires's avatar
joao_pires
Frequent Visitor
8 years ago
Solved

Persist text when publish report custom visual

Hi,

In custom visual :

When i publish report, how  persist or get text 

to input how to custom visual Text toFilter does?

For now the filters are applied.

 

thanks

 

  • v-viig's avatar
    v-viig
    8 years ago

    Don't call this.visualHost.persistProperties in enumerateObjectInstances method since such implementation might cause an infinite update loop if Format Panel is opened.

    Are there any exceptions? Can you share the embedded Power BI report to debug it?

     

    Ignat Vilesov,

    Software Engineer

     

    Microsoft Power BI Custom Visuals

    [email protected]

3 Replies

    • joao_pires's avatar
      joao_pires
      Frequent Visitor

      Hi ,

      thanks your reply.

      I folowed this steps but in sandbox mode works well, but when package this visual not works. why?

      Help me pls.

      my code:

        Capabilities

       "objects": {
              "settings": {
                  "properties": {
                      "config": {
                          "type": {
                              "text": true
                          }
                      },
                      "show": {
                          "type": {
                              "bool": true
                          }
                      }
      
                  }
              },
              "general": {
                  "displayName": "General",
                  "displayNameKey": "formattingGeneral",
                  "properties": {
                      "selection": {
                          "displayName": "Selection",
                          "type": {
                              "text": true
                          }
                      },
                      "filter": {
                          "type": {
                              "filter": true
                          }
                      },      

        method Update:

       this.values = JSON.parse(getValue(this.dataView.metadata.objects, "settings", "config", "No items"));
                 let items="";
                 this.values.forEach(element => {
                      items+=element+"\n";
                  });
                 
      $("#q").val(items);

      Enumerate:

       

       public enumerateObjectInstances(options: EnumerateVisualObjectInstancesOptions): VisualObjectInstance[] | VisualObjectInstanceEnumerationObject {
                 // return VisualSettings.enumerateObjectInstances(this.settings || VisualSettings.getDefault(), options);
                   let objectName = options.objectName;
                  let objectEnumeration: VisualObjectInstance[] = [];
               
                 
      
                  this.visualHost.persistProperties(<VisualObjectInstancesToPersist>{
                      merge: [{
                          objectName: "settings",
                          selector: null,
                          properties: {
                              config: JSON.stringify(this.values) || "{}",
                              show:true
                          }
                      }]
                  });
      
                  return objectEnumeration;
      
              }

      DataView :

      • v-viig's avatar
        v-viig
        Community Champion

        Don't call this.visualHost.persistProperties in enumerateObjectInstances method since such implementation might cause an infinite update loop if Format Panel is opened.

        Are there any exceptions? Can you share the embedded Power BI report to debug it?

         

        Ignat Vilesov,

        Software Engineer

         

        Microsoft Power BI Custom Visuals

        [email protected]