Insert A Value In Parameter Text Box By Script

Hello,

I have a parameter text box in my dashboard and I want to set up a script to take a value from a table and put it into my view parameter. My problem is how can I send this value to the parameter. I didn’t find anything regarding text box scripting.
Thank you!

1 Like

Hi Costin,

To get data from a particular cell in a Table control, you will want to do something like this:

var args = dundas.Utility.getAdapterHitTestArguments(e.originalEvent, table1);
var rowIndex = table1.control.hitTest(args.offsetX, args.offsetY, args.target).rowIndex;
var cellText = table1.metricSetBindings[0].dataResult.cellset.rows[rowIndex].members[0].caption;

From here, you just need to update your view parameter. Depending on the type of data it can vary but with text you’re just looking to change the .value property.

I’d recommend taking a look at these samples as they will give you a great start on this.

https://www.dundas.com/support/developer/script-library/filter-and-parameter/

1 Like

Thank @jeff ! But my case is the following: The filter is connected to a placeholder. Inside the dashboard, this filter is a text box. How can I put a value inside this text box to be taken by the filter or to set directly the value for my placeholder?

I’m a bit unclear on what you mean by ‘placeholder’ as the filter control would be linked to a View Parameter.

I just did a test where i am setting the underlying View Parameter and then updating the filter control separately. Maybe give this a try?

var canvasService = this.getService(“CanvasService”);
canvasService.canvasAdapter.control.viewParameters[1].parameterValue.values[0].uniqueName = “Brazil.Country”;
parameterTextBox1.control.value = “Brazil”;
canvasService.canvasAdapter.control.viewParameters[1].refreshAllAdapters();

1 Like

@costin.manea

I would like to know why you need to do this.
From what you said you have a Table that has values and a View Parameter that you want a value from the table to be in that view Parameter, is this correct?

If it is then Dundas has all those in there by default. This might just be a configuration of the View Parameter.

We are talking about filtering the table correct? (that what view Parameter are mostly used for).

1 Like

Thanks a lot @jeff and @james.davis! The second script of @jeff it fits perfect for me. Sorry for not providing you so many details.

Hi Jeff, I’ve been using this script on a table however I find when the table is filtered the member position changes. Is there a way of adapting it to be more specific e.g. specify the column heading?

Hello @shane.o.sullivan,

I think this script will help you:
var x=table7.metricSetBindings[0].dataResult.cellset.rows[0].members[2].caption;

You can replace members[2] with your column and also the row[0] with a specified row.

Hi Costin,

Thanks, this worked perfectly!

1 Like