cancel
Showing results for 
Search instead for 
Did you mean: 

Extracting Dimension Values from a Data Source

0 Kudos

I wanted to create a control that would extract all of the dimensions from a data source, and then create a single string with comma separated values.

I started with the simple table sample and kept the following component:

<property
id="column1"
title="Column X"
type="ResultCellList"
group="DataBinding">
<option name="includeFormattedData" value="true"/>
<option name="includeMetadata" value="true"/>
</property>

I then modified the afterUpdate function to:

this.afterUpdate = function() {

   if(JSON.stringify(this.metadata()).length){

      try{

         for(i=1; i < this.metadata().dimensions[1].members.length-1; i++){

            if(i==1){

               commaStr = this.metadata().dimensions[1].members[i].text;

            }

            else{

               tempStr=commaStr;              

               commaStr = tempStr + ', ' + this.metadata().dimensions[1].members[i].text;

            }

         }

      alert(commaStr);

      }catch(e)

         {

      }

   }

};

This does give me the output that I want:

string_1, string_2, string_3, string_4, ...

My questions are:

  • Currently, I have to assign a data source through Data Binding: Data Source and Column 1, in the Design Studio interface.
    • I want to only assign the data source, since I am not showing the data selected in Column 1.
  • I am using ResultCellList, should I be using ResultSet? If so, then how would my code change?
  • Are there definitions somewhere that explains exactly how to use the ResultSet, ResultCellList, and others?
  • After assigning the Data Source, the AfterUpdate function gets called. What is passed to the AfterUpdate function? Is there a way to access the data source and its contents in this AfterUpdate call?

Thanks,

Robert

Accepted Solutions (1)

Accepted Solutions (1)

Martin-Pankraz
Active Contributor
0 Kudos

Hi Robert,

probably you already had a look into the developer guide but I would like to point you in particular to the pages 28 and 43 ff on the matter of using ResultSet or ResultCellList.

http://help.sap.com/businessobject/product_guides/AAD14/en/ds14_dev_guide_en.pdf

When using ResultSet you can set the associated variable to "{}", which means all of the data will be send to your control. That way you don't need to set any columns. For convenience put a default value in your contribution.xml file.

Changing your property's type from ResultSet to ResultCellList should be enough.

Now on to your last question, I would suggest using your favorite browser's developer tools which you could access via F12 and to put a breakpoint near afterUpdate. In addition to that you could output your metadata json with console.log(JSON.stringify(<your var name>)) to learn its structure and content. I wouldn't recommend the alert function as the json can get quite lengthy.

Hope this helps.

Regards

Martin

0 Kudos

Thanks, Martin.

Answers (0)