cancel
Showing results for 
Search instead for 
Did you mean: 

Events for table or columns

Former Member
0 Kudos

Hello experts,

I have a table and multiple lines in it, The user will enter some extra info into couple of columns for each row manually.

I have created an event (onchange) for these columns and it works fine if i select the row first, but if i enter a value into to field without selecting the row, the event won't triggered ?

Is there any way to select the row when i click on the field (inputfield)  or any other suggestion to this ?

Regards,

Yasin

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi

if you use an input field perhaps you can try using onEnter for the specific field?

Otherwise, you can add a button at the bottom and call it 'Save'. Let the user enter everthing

at the end he can press on the button. The button leads to an action where you go over

the entire table and extract the value of each cell.

p.s you may also like to look up this pdf and see what you can do with tables:

"Developing State-of-the-Art Table User Interfaces in  Web Dynpro Java"

Here is the original :

regards

yuval

Former Member
0 Kudos

Hi Yuval,

Thanks for your reply, also i forgot to say i am on NWDS 7.3 and i could do this on NWDS 7.0.

I have tried onEnter and Table behaviours but no help so far, Let me explain it from a screenshot.

What i am trying to do is to calculate some values based on input values entered by user manually and i created an event for this,

If I select a line put some values into cells and press enter, everything works fine,

BUT, when i click to an another line and put some values in its respective cells (without selecting the line) it won't work for this second line, still for the first one as the first one is still selected..

I would go for a loop and calculate all the values for the table lines but i do not want this at the moment.

And i can do this kind of thing on 7.0 but can not find a way to do this on 7.3  yet.

Thanks again,

Regards,

Yasin

Former Member
0 Kudos

Hi Yasin

nasel senez?

1. Check your context node and see if table is selected.

2. what I mean is this: when you select
    a new line (on the side) , the line should be highlighted. That means it gets focus
    and now you can refer to it as wdContext.current<nameOfYourTableNode>Element().

3. As far as I understand what you want to achieve is to get a cell value calculated
    based on the some entries. This can be in two ways: either by hitting
    'enter` or by selecting a new line (for the previous line), or both 🙂

3. The problem is that changing row does not mark the newly selected line as selected.   
     Recheck your context node!!! not the table properties!!!

4. Are you familiar with 'calculated attributes'? You should.

    See here and here of course.

regards

yuval

Former Member
0 Kudos

Hi again Yuval,

I am fine and thanks for asking I hope you are fine too.

Thanks for your 'helpful answer', i will look into calculated values, also i can solve this by looping the table for every input.

However, the problem i have is still there, let me explain it another way,

If i add a column for a 'link to action'  and name it 'Delete' and use this to delete for each respective line, it will not delete its respective line but the selected (highlighted) one, right ?

Let's say i have 5 rows of record, if i select the second line (highlight it) and press the 'Delete' on the third line or any other line it will always delete the selected one(second one), not the particular row that delete link is on and pressed..

I can not get the row that i pressed delete button deleted as current<Tab>Element, but the selected (highlighted) one only But i need to get the index of the row that i pressed 'Delete'.

Thanks again,

Regards,

Yasin

Former Member
0 Kudos

Hi

Yasin, i understand you fully.....

I think you may want to see this solution

http://www.urz.uni-heidelberg.de/saphelp/helpdata/DE/ed/785a42793d1653e10000000a155106/content.htm

here you can select each and every cell regardless of the currently selected row.

Regards

Yuval

Former Member
0 Kudos

Hi Yasin

Please have a look at this nice tutorial titled "Play Soduko - Using Table Cell Variants in Web Dynpro Java". The authoer there explains how we can make each cell  "act" on its own,

regardless whether the row is chosen or not.

regards

yuval

Former Member
0 Kudos

Dear Yuval,

This solves my problem, you have my appreciation,

Thanks a'lot,

Regards,

Yasin

Former Member
0 Kudos

Hi Yasin

ok. Here is a full blown solution:

When you create your table context add the following attribute:

SelectedTableCellVariant of type string

When you create your table, set each element:

element.SelectedTableCellVariant("Variant_1");

UIELEMENTS

1. set Table property "SelectionMode" to "none"

2. Right click every column, except the calculated one, and select insert CellVariant, choose
    type TableSingleMarkedCell.

3. Once crated, set its attribute "attributeToMark" to point to the same context attribute your
    original input field points (let's call it "Table.FM").

4. Direcly under your context add one more attribute and call it "AttributePointer" . To set its
    type  go to three dots, under Dictionary Simple Type under XX.XX.XX.uielementdefinitions
    select AttributePointer.

5. Bind the TableSingleMarkedCell property "markedData" to this "AttributePointer".

6. Set TableSingleMarkedCell property "variantKey" to "Variant_1".

7. Add an inputField to this TableSingleMarkedCell and bind it "Table.FM".

8. Create an onEnter eventHanlder for your your original inputField (under the columnn, not
    under the TableSingleMarkedCell) , call it "calculateAylik" (with reference to your

    calculated col).

9. The code should look something like this:

   

     try{

       IWDAttributepointer pointer = wdContext.currentContextElement().getAttributePointer();

       String colName = pointer.getAttributeInfo().getName();

        if (colName.equalIgnoreCase("FM"))

    {

          int row = pointer.getNodeElement().index();

          //to retrieve the value of this particular cell
         String fm = wdContext.NodeTable().getTableElementAt(row).getFM();

        

         //perform your calculation

             String calculated = .............................

        //set the value you calculated

        wdContext.NodeTable().getTableElementAt(row).setCalculated(calculated);

        

     }

          catch(Exception e)

     {

     }

Now create an event handler for each inputFierd in each column following the pattern
I set out in this method. Once you click on enter, the appropriate cell in each row will be
filled out with the result calculated based on the input of the particular cell you choose

in the same row. No need to selected each row separately.

regards

yuval

Former Member
0 Kudos

Hi Yasin

You're welcome.

Regards

Yuval

Answers (0)