Pass multiple selected table rows to a viewparameter

Hi All,

I am trying to make a feature where users can select multiple table values which will then load into a viewparameter, and have a button that when clicked opens another dashboard with this viewparameter applied. I understand that it would be easier to use a pre-loaded filter for this however due to the way our data is set up I don’t think this is an option. I have an intermediate button to test that the multiple selected rows are being picked up, however the viewparameter isn’t being applied to the target dashboard for some reason when the open target dashboard button is pressed.

Here is the code that is executed on the intermediate button that loads the member values in. I am not too familiar with javascript. Is the written function being executed properly? What’s going on here?

//get selected table hierarchy members
var members = table1.getSelectedRowHierarchyMembers();

    //display in text box - this is just a test to ensure data is selecting correctly
    var text = "Selected";
    for(i = 0; i < members.length; i++) {
      text += " | " + members[i].caption;
    }
    label8.labelText = text;

    //set selected table members to CustomerFilter parameter
    var viewParameter = this.parentView.control.getViewParameterByName("CustomerFilter");

    viewParameter.parameterValue.clearTokens();
    viewParameter.parameterValue.clearValues();

    def.done(function (members) {
        // loop through all the members
        members.forEach(function (member) {
                viewParameter.parameterValue.values.push(member.loadMemberValue());
            
        });
     
        // Set the last modified time so this parameter takes precedence over any others
        viewParameter.invalidateParameterValueLastModifiedTime();
     
        // Update all the connected adapters with the newly modified values
        // Includes data visualizations and filter controls
        viewParameter.refreshAllAdapters();
    });

Hi Nicolas,

First, I think your code would not work because you have no definition for def. Second, I believe you have to create a member object for each of your selected value.

Here’s a sample code of how we are passing multiple selected values to a view parameter:

var sr = tblFunction.getSelectedRowHierarchyMembers();

if(sr)
{ 	
  	var vpFunction = this.parentView.control.getViewParameterByName("vpFunction");
  	
  	vpFunction.parameterValue.clearTokens();
  	vpFunction.parameterValue.clearValues();
  
	sr.forEach(assignValues);
  
  	vpFunction.invalidateParameterValueLastModifiedTime();
	vpFunction.refreshAllAdapters();
}


function assignValues(row)
{
	var filterValue = new dundas.data.MemberValue({
    	hierarchyUniqueName: "[Function].[FunctionLabel]",
    	levelUniqueName: "[Function].[FunctionLabel].[FunctionLabel]",
    	uniqueName: "[Function].[FunctionLabel].&[" + row.caption + "]"
		});
  
	vpFunction.parameterValue.values.push(filterValue);
  
}

I hope this helps.

Regards,

Renzi

Thanks for your help on this renzi.