Overview

Skill Level: Beginner

IBM BPM

Let's take a problem statement on accessing index of a row, cell of the Table control of BPM UI Toolkit.

Ingredients

IBM BPM v8.6/IBM BAW v18

Step-by-step

  1. Problem

    I have a table with three columns, like –

    image

    When I select ‘No’ from the Selection column the other two cells of that row should be disabled and if I select ‘Yes’, cells should be editable.

  2. First we need to know the index of the Selection radio button –

    // Get the row index of checked radio button

    var index = me.ui.getIndex();

  3. Then, we need to get the Coach View instance for the “Name” and “Value” cells of that row –

    // sampleList1, name1 and value1 are the control ids of the table, name textbox and value textbox respectively

    var nameView = page.ui.get(‘/sampleList1/name1[‘+index+’]’);

    var valueView = page.ui.get(‘/sampleList1/value1[‘+index+’]’);

  4. Next, we need to get the selected value of the radio button for that row –

    me.getData();

  5. Finally, to achieve the requirement, we need to combine the above piece of codes and add a logic to set the visibility of the textboxes based on the selected value of the radio button –

    // Get current row index

    var index = me.ui.getIndex();

     

    // Get Coach View instance of the name and value textbox

    var nameView = page.ui.get(‘/sampleList1/name1[‘+index+’]’);

    var valueView = page.ui.get(‘/sampleList1/value1[‘+index+’]’);

     

    // Set the visibility of the textboxes based on the selected value of the radio button

    if(me.getData() == “Y”){

        nameView.context.options._metadata.visibility.set(‘value’, “DEFAULT”);

        valueView.context.options._metadata.visibility.set(‘value’, “DEFAULT”);

    } else {

        valueView.context.options._metadata.visibility.set(‘value’, “READONLY”);

        nameView.context.options._metadata.visibility.set(‘value’, “READONLY”);

    }

Join The Discussion