spacer
cornerspacercorner
Reply
Occasional Contributor
MCKurt
Posts: 5
Registered: 06-29-2010
0 Kudos

Getting data from currently selected row in a grid

Hi, thanks in advance for your help.

 

I have a grid that is getting it's data from table business object.  When the user selects a row, I would like to populate form fields on the same form (the grid displays only a subset of the fields available - this is like a summary/detail view).  I have a function for when user selects row, and I do an assign values activity.  My current code looks like:

 

Local.Form_Field1=BusinessObject.Field1

 

When the user selects a row, it takes the value from the 1st row and puts it in the form field.  The problem is that the BusinessObject is always tied to the first row, if I select the second row, it still puts the first row data in the field.  What is the expression to get the BusinessObject tied to the current row?

 

Thanks.

 

Valued Contributor
Greg
Posts: 179
Registered: 05-19-2010

Re: Getting data from currently selected row in a grid

You have to use ProcessContext.UserInput.

Occasional Contributor
MCKurt
Posts: 5
Registered: 06-29-2010
0 Kudos

Re: Getting data from currently selected row in a grid

Thanks!  That did it.

 

Regular Advisor
RKushner
Posts: 103
Registered: 05-20-2010
0 Kudos

Re: Getting data from currently selected row in a grid

I was just going to post an almost identical question. Thanx very much!!!

 

The designer manual explains "When user select row" with all of the following detail:

 

"Do this when the user selects a row"

 

That much I could have guessed!!!

Regular Advisor
RKushner
Posts: 103
Registered: 05-20-2010
0 Kudos

Re: Getting data from currently selected row in a grid

When I try to assign a variable, Local.Var with the value, ProcessContext.UserInput, I get this error. And I still need to specify which column to use...

 

 

Non-invocable member 'Metastorm.Runtime.Core.ProcessContext.UserInput' cannot be used like a method.

 

The only thing that the designer manual says is:

 

"Returns the text entered by the user into the current field. (If the form field contains a collection of data, return it as

a list.) Note that UserInput variable can be accessed only from Expression Builder. (Expression Builder->Business

Object->ProcessContext)."

 

What about a grid? What about using it on the left side of an assignment?

Frequent Advisor
Carolyn
Posts: 65
Registered: 06-30-2010

Re: Getting data from currently selected row in a grid

Are you writing it in c#? Normally when I get that error it means I've put round brackets after a property, where they shouldn't be. I'm assuming you want a column number too, so maybe you do ProcessContext.UserInput[0] using square brackets round the column number.

Esteemed Contributor
Jerome҉
Posts: 744
Registered: 05-18-2010

Re: Getting data from currently selected row in a grid

 


RKushner wrote:

When I try to assign a variable, Local.Var with the value, ProcessContext.UserInput, I get this error. And I still need to specify which column to use...

 

 

Non-invocable member 'Metastorm.Runtime.Core.ProcessContext.UserInput' cannot be used like a method.

 

The only thing that the designer manual says is:

 

"Returns the text entered by the user into the current field. (If the form field contains a collection of data, return it as

a list.) Note that UserInput variable can be accessed only from Expression Builder. (Expression Builder->Business

Object->ProcessContext)."

 

What about a grid? What about using it on the left side of an assignment?


Square brakets not round ones: ProcessContext.UserInput[x] not the ProcessContext.UserInput(x) you may be using.

 

Occasional Advisor
Eric Schiavo
Posts: 12
Registered: 06-02-2010
0 Kudos

Re: Getting data from currently selected row in a grid

I know this is an old thread, but my issue is directly related to this. I have a form with multiple grids on it. The first grid is a parent grid to the second. When I select a row in the parent grid, I need to display rows in the child grid based on a column from the parent grid. I currently have a parameter in the BO of the child grid set to ProcessContext.UserInput[0]. This all works fine, but my problem is that when I select a row in the child grid, I need to save a value from a cell in that grid. Using ProcessContext.UserInput just writes over the original value, which ends up removing or displaying incorrect rows in the child grid. Is there any way to store two different values from two different grids on a form? I know this was accomplished in 7.6 with %field.grd1[x], but I don't see anything like that in v9. Any help would be appreciated!

Occasional Advisor
Eric Schiavo
Posts: 12
Registered: 06-02-2010
0 Kudos

Re: Getting data from currently selected row in a grid

Got a response from someone on another forum with a solution. Set a local variable with the value from the parent grid and set the BO parameter of the child grid with this local value, not the UserInput value. Then get UserInput of child grid into another local variable.
Advisor
Robert Vignerot
Posts: 38
Registered: 11-15-2011
0 Kudos

Re: Getting data from currently selected row in a grid

I was looking for this myself today and I was suprised to only see references to ProcessContext.UserInput and to assigning the value to a local variable.  It is also possible to refer to the field directly although the API wasn't fully documented.  To do this use:

 

Fields.grdName.SelectedRow["colName"].ToString()

 

where "grdName" and "colName" are the names of the grid and column respectively.  This will only work if the grid is marked as having dependants.

line spacer line
spacerFollow Metastorm on:
spacer Twitter YouTube Blog iTunes LinkedIn Metastorm Community Central, MC2
spacer Copyright © 2011 OpenText Corporation. All Rights Reserved.spacer About Metastormspacer Privacyspacer Legalspacer Site Mapspacer RSSspacer Contact Us
Microsoft Gold Certified Partner
Powered by Windows Azure
line spacer line