Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AVEVA™ Work Tasks

Accessing Values of a Selected Row Through Other Controls

Accessing Values of a Selected Row Through Other Controls

  • Last UpdatedJun 25, 2024
  • 2 minute read

You can access the column values for a selected row of a data grid through other controls.

Data Grid

In the following example, we create a lookup named Employee, with a column named Salary that holds the salaries of all the employees. We create a form with Data Grid control and configure the lookup to the Data Grid control. We also add a Button and Text control to the form. Let us now consider that we want to fetch the salary of a selected employee .We can access this value through the Text control in the form as follows:

  1. Create a lookup and name it as Employee.

  2. Create a Grid Configuration using the Employee lookup.

  3. Create a form and add a Data Grid control.

  4. Modify properties of the Data Grid control as follows:

    1. In the Basic tab, set the Configuration Name property to the grid configuration created in Step 2.

  5. Add a Button and Text control to the form.

  6. Set the Button Type property of the Button control to Custom.

  7. Code the script for the On Click event of the Button control as follows:

    var gridSelecedValue=control.findByXmlNode("Grid1").selectedValue;

    control.findByXmlNode("Textinput1").value=gridSelecedValue.<ColumnName>;

The script uses the selectedValue property to fetch the column value of selected row. When you click the button, the Text control gets updated with the Salary value (column), of the selected Employee.

Hierarchical Grid

In the following example, we create a hierarchical data grid with lookups named Work Order (parent lookup), and Jobs (child lookup). We create a form and consume this grid configuration in the form. We also add a Button and Text control to the form. Let us now consider that we want to fetch the Job_Id of a selected Job. We can access this value through the Text control in the form as follows:

  1. Create a Hierarchical Data Grid using the lookups Work Order (parent lookup) and Jobs (child lookup). For more information on creating a Hierarchical Data Grid, see the topic Create a Hierarchical Data Grid.

  2. Create a form and consume the grid configuration created in step 1.

  3. Add a Button and Text control to the form.

  4. Set the Button Type property of the Button control to Custom.

  5. Code the script for the On Click event of the Button control as follows:

    var gridSelecedValue =control.findByXmlNode("Grid1").selectedValue;

    control.findByXmlNode("Textinput1").value=gridSelecedValue.<ParentLookupName>.<ChildLookupName>.<ColumnName>;

    The script uses the selectedValue property to fetch the column value of selected row. When you click the button, the Text control gets updated with the Job_Id (column), of the selected Job.

    In This Topic
    Related Links
    TitleResults for “How to create a CRG?”Also Available in