Page 1 of 1

Programmatic way to select a row in a grid - (click the row

Posted: Thu Jun 20, 2013 10:38 pm
by HowardA
I want to use java script to click a particular row in a grid. Is that possible? (by programmatically clicking this row, it would perform the action that has been scripted in the onrowclick event).

Re: Programmatic way to select a row in a grid - (click the row

Posted: Fri Jun 21, 2013 4:55 pm
by Scott Klement
At the moment, there is no good way to programmatically trigger the onrowclick event of a grid. (There are "hacks" that might work, but they may break in future versions of Profound UI, so I would not recommend them)

Here's an idea that might work, though... can you put your onrowclick logic into it's own function? For example, create a JavaScript file in userdata/custom/js and code something like this:

function myFunc() {
... move existing onrowclick logic here...
}

Then have the onrowclick event call myFunc().

Then, you could run the same function anywhere else you need it, just by calling myFunc() elsewhere in your code.

Re: Programmatic way to select a row in a grid - (click the row

Posted: Fri Jun 21, 2013 5:32 pm
by HowardA
Thanks Scott,
I was looking for an quick/easy way to deal with a specific issue I have with a grid. When calling the program that loads the display, a subfile is built, with several rows but the parameter passed into this program identifies one particular row of that subfile. when the subfile is displayed, I wanted to execute the onrowclick logic for that row (which relates the parm passed in, thus is not known until run time). I could put the logic in another function, but still need to launch it when the page is loaded, based on the appropriate row(from the passed in parm). (the logic being executed extracts a bunch of hidden subfile fields from the row using several of these statements:
changeElementValue("CSUNIT_A", get("CSUNIT." + row));

Thanks again for your assistance!

Re: Programmatic way to select a row in a grid - (click the row

Posted: Mon Jun 24, 2013 12:39 pm
by Scott Klement
One approach might be to put a hidden numeric field on the screen, maybe the field would be named 'CLICKRRN' or something similar.

Put some Javascript code in your screen's "onload" event that retrieves the value of the hidden field, and if it's >0, call your function and pass the value of the CLICKRRN field as a parameter.

The "onrowclick" function would call the same function, and pass the row that the user clicked on as a parameter.

Re: Programmatic way to select a row in a grid - (click the row

Posted: Mon Jun 24, 2013 1:41 pm
by HowardA
That sounds like an easy way to go about it. I'll go that route, and thanks!